You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
Another Python 3 closure grammar bug
This commit is contained in:
BIN
test/bytecode_3.2/05_closure_bug.pyc
Normal file
BIN
test/bytecode_3.2/05_closure_bug.pyc
Normal file
Binary file not shown.
BIN
test/bytecode_3.5/05_closure_bug.pyc
Normal file
BIN
test/bytecode_3.5/05_closure_bug.pyc
Normal file
Binary file not shown.
25
test/simple_source/def/05_closure_bug.py
Normal file
25
test/simple_source/def/05_closure_bug.py
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# Tests bug in Python 3
|
||||||
|
|
||||||
|
# load_closure ::= LOAD_CLOSURE BUILD_TUPLE_1
|
||||||
|
|
||||||
|
# Python 3.5
|
||||||
|
# mkfunc ::= load_closure LOAD_CONST LOAD_CONST MAKE_CLOSURE_0
|
||||||
|
|
||||||
|
# Python 3.2
|
||||||
|
# mkfunc ::= load_closure LOAD_CONST MAKE_CLOSURE_0
|
||||||
|
|
||||||
|
# mkfuncdeco0 ::= mkfunc
|
||||||
|
# mkfuncdeco ::= expr mkfuncdeco0 CALL_FUNCTION_1
|
||||||
|
# designator ::= STORE_FAST
|
||||||
|
# funcdefdeco ::= mkfuncdeco designator
|
||||||
|
# stmt ::= funcdefdeco
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
from functools import wraps
|
||||||
|
|
||||||
|
def contextmanager(func):
|
||||||
|
@wraps(func)
|
||||||
|
def helper(*args, **kwds):
|
||||||
|
return _GeneratorContextManager(func, *args, **kwds)
|
||||||
|
return helper
|
@@ -528,10 +528,19 @@ class Python3Parser(PythonParser):
|
|||||||
'expr GET_ITER CALL_FUNCTION_1' %
|
'expr GET_ITER CALL_FUNCTION_1' %
|
||||||
('expr '* token.attr, opname),
|
('expr '* token.attr, opname),
|
||||||
opname, token.attr, customize)
|
opname, token.attr, customize)
|
||||||
rule = ('mkfunc ::= %s load_closure BUILD_TUPLE_1 LOAD_CONST LOAD_CONST %s'
|
|
||||||
|
rule = ('mkfunc ::= %s load_closure LOAD_CONST %s'
|
||||||
|
% ('expr ' * token.attr, opname))
|
||||||
|
|
||||||
|
# Python 3.5+ instead of above?
|
||||||
|
rule = ('mkfunc ::= %s load_closure LOAD_CONST LOAD_CONST %s'
|
||||||
|
% ('expr ' * token.attr, opname))
|
||||||
|
|
||||||
|
self.add_unique_rule(rule, opname, token.attr, customize)
|
||||||
|
rule = ('mkfunc ::= %s load_closure load_genexpr %s'
|
||||||
% ('expr ' * token.attr, opname))
|
% ('expr ' * token.attr, opname))
|
||||||
self.add_unique_rule(rule, opname, token.attr, customize)
|
self.add_unique_rule(rule, opname, token.attr, customize)
|
||||||
rule = ('mkfunc ::= %s load_closure BUILD_TUPLE_1 LOAD_GENXPR LOAD_CONST %s'
|
rule = ('mkfunc ::= %s load_closure LOAD_CONST %s'
|
||||||
% ('expr ' * token.attr, opname))
|
% ('expr ' * token.attr, opname))
|
||||||
self.add_unique_rule(rule, opname, token.attr, customize)
|
self.add_unique_rule(rule, opname, token.attr, customize)
|
||||||
return
|
return
|
||||||
|
Reference in New Issue
Block a user