You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 16:59:52 +08:00
bug in 3.x importlists
consts.py: add rule for importlists. imports weren't separated by ', '. parser.py: Make importlist a list type of node. test/* add test for importlist
This commit is contained in:
BIN
test/bytecode_3.5/04_importlist.pyc
Normal file
BIN
test/bytecode_3.5/04_importlist.pyc
Normal file
Binary file not shown.
7
test/simple_source/bug35/04_importlist.py
Normal file
7
test/simple_source/bug35/04_importlist.py
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# Had bug in 3.x in not having semantic importlist rule
|
||||||
|
def main(osp, Mfile, mainpyfile, dbg=None):
|
||||||
|
try:
|
||||||
|
from xdis import load_module, PYTHON_VERSION, IS_PYPY
|
||||||
|
return PYTHON_VERSION, IS_PYPY, load_module
|
||||||
|
except:
|
||||||
|
pass
|
@@ -30,13 +30,16 @@ class PythonParser(GenericASTBuilder):
|
|||||||
|
|
||||||
def __init__(self, AST, start, debug):
|
def __init__(self, AST, start, debug):
|
||||||
super(PythonParser, self).__init__(AST, start, debug)
|
super(PythonParser, self).__init__(AST, start, debug)
|
||||||
self.collect = frozenset(
|
# FIXME: customize per python parser version
|
||||||
['stmts', 'except_stmts', '_stmts', 'load_attrs',
|
nt_list = [
|
||||||
'exprlist', 'kvlist', 'kwargs', 'come_froms', '_come_from',
|
'stmts', 'except_stmts', '_stmts', 'load_attrs',
|
||||||
# Python < 3
|
'exprlist', 'kvlist', 'kwargs', 'come_froms', '_come_from',
|
||||||
'print_items',
|
'importlist',
|
||||||
# PyPy:
|
# Python < 3
|
||||||
'kvlist_n'])
|
'print_items',
|
||||||
|
# PyPy:
|
||||||
|
'kvlist_n']
|
||||||
|
self.collect = frozenset(nt_list)
|
||||||
|
|
||||||
def ast_first_offset(self, ast):
|
def ast_first_offset(self, ast):
|
||||||
if hasattr(ast, 'offset'):
|
if hasattr(ast, 'offset'):
|
||||||
|
@@ -269,6 +269,7 @@ TABLE_DIRECT = {
|
|||||||
'kv2': ( '%c: %c', 1, 2 ),
|
'kv2': ( '%c: %c', 1, 2 ),
|
||||||
'mapexpr': ( '{%[1]C}', (0, maxint, ', ') ),
|
'mapexpr': ( '{%[1]C}', (0, maxint, ', ') ),
|
||||||
'importstmt': ( '%|import %c\n', 2),
|
'importstmt': ( '%|import %c\n', 2),
|
||||||
|
'importlist': ( '%C', (0, maxint, ', ') ),
|
||||||
'importfrom': ( '%|from %[2]{pattr} import %c\n',
|
'importfrom': ( '%|from %[2]{pattr} import %c\n',
|
||||||
(3, 'importlist') ),
|
(3, 'importlist') ),
|
||||||
'importstar': ( '%|from %[2]{pattr} import *\n', ),
|
'importstar': ( '%|from %[2]{pattr} import *\n', ),
|
||||||
|
Reference in New Issue
Block a user