You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Handle 3.5 with [as]
scanner35.py: Fix a small variable-name typo
This commit is contained in:
BIN
test/bytecode_3.4/05_with.pyc
Normal file
BIN
test/bytecode_3.4/05_with.pyc
Normal file
Binary file not shown.
BIN
test/bytecode_3.5/05_with.pyc
Normal file
BIN
test/bytecode_3.5/05_with.pyc
Normal file
Binary file not shown.
2
test/simple_source/stmts/05_with.py
Normal file
2
test/simple_source/stmts/05_with.py
Normal file
@@ -0,0 +1,2 @@
|
||||
with (sys) as f:
|
||||
print(f)
|
@@ -37,6 +37,9 @@ rm_op(opname, opmap, 'STORE_LOCALS', 69)
|
||||
def_op('YIELD_FROM', 72)
|
||||
def_op('LOAD_CLASSDEREF', 148)
|
||||
|
||||
# These are removed since Python 3.4
|
||||
rm_op(opname, opmap, 'WITH_CLEANUP', 81)
|
||||
|
||||
# These are new since Python 3.4
|
||||
def_op('BINARY_MATRIX_MULTIPLY', 16)
|
||||
def_op('INPLACE_MATRIX_MULTIPLY', 17)
|
||||
|
@@ -447,6 +447,8 @@ def python_parser(version, co, out=sys.stdout, showasm=False,
|
||||
for t in tokens:
|
||||
print(t)
|
||||
|
||||
# For heavy grammar debugging
|
||||
# parser_debug = {'rules': True, 'transition': True, 'reduce' : True}
|
||||
p = get_python_parser(version, parser_debug)
|
||||
return parse(p, tokens, customize)
|
||||
|
||||
|
@@ -544,6 +544,15 @@ class Python35onParser(Python3Parser):
|
||||
"""
|
||||
# this optimization is only used in Python 3.5 and beyond
|
||||
_ifstmts_jump ::= c_stmts_opt
|
||||
|
||||
# Python 3.5 has WITH_CLEANUP_START/FINISH
|
||||
withstmt ::= expr SETUP_WITH with_setup suite_stmts_opt
|
||||
POP_BLOCK LOAD_CONST COME_FROM
|
||||
WITH_CLEANUP_START WITH_CLEANUP_FINISH END_FINALLY
|
||||
|
||||
withasstmt ::= expr SETUP_WITH designator suite_stmts_opt
|
||||
POP_BLOCK LOAD_CONST COME_FROM
|
||||
WITH_CLEANUP_START WITH_CLEANUP_FINISH END_FINALLY
|
||||
"""
|
||||
|
||||
class Python35onParserSingle(Python35onParser, PythonParserSingle):
|
||||
|
@@ -127,7 +127,7 @@ class Scanner35(scan3.Scanner3):
|
||||
if target < inst.offset:
|
||||
if (inst.offset in self.stmts and
|
||||
self.code[inst.offset+3] not in (END_FINALLY, POP_BLOCK)
|
||||
and offset not in self.not_continue):
|
||||
and inst.offset not in self.not_continue):
|
||||
opname = 'CONTINUE'
|
||||
else:
|
||||
opname = 'JUMP_BACK'
|
||||
|
Reference in New Issue
Block a user