You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09: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):
|
||||
super(PythonParser, self).__init__(AST, start, debug)
|
||||
self.collect = frozenset(
|
||||
['stmts', 'except_stmts', '_stmts', 'load_attrs',
|
||||
'exprlist', 'kvlist', 'kwargs', 'come_froms', '_come_from',
|
||||
# Python < 3
|
||||
'print_items',
|
||||
# PyPy:
|
||||
'kvlist_n'])
|
||||
# FIXME: customize per python parser version
|
||||
nt_list = [
|
||||
'stmts', 'except_stmts', '_stmts', 'load_attrs',
|
||||
'exprlist', 'kvlist', 'kwargs', 'come_froms', '_come_from',
|
||||
'importlist',
|
||||
# Python < 3
|
||||
'print_items',
|
||||
# PyPy:
|
||||
'kvlist_n']
|
||||
self.collect = frozenset(nt_list)
|
||||
|
||||
def ast_first_offset(self, ast):
|
||||
if hasattr(ast, 'offset'):
|
||||
|
@@ -269,6 +269,7 @@ TABLE_DIRECT = {
|
||||
'kv2': ( '%c: %c', 1, 2 ),
|
||||
'mapexpr': ( '{%[1]C}', (0, maxint, ', ') ),
|
||||
'importstmt': ( '%|import %c\n', 2),
|
||||
'importlist': ( '%C', (0, maxint, ', ') ),
|
||||
'importfrom': ( '%|from %[2]{pattr} import %c\n',
|
||||
(3, 'importlist') ),
|
||||
'importstar': ( '%|from %[2]{pattr} import *\n', ),
|
||||
|
Reference in New Issue
Block a user