Handle 3.5 with [as]

scanner35.py: Fix a small variable-name typo
This commit is contained in:
rocky
2016-05-04 22:12:36 -04:00
parent e4ba73adfb
commit c85496a92d
7 changed files with 17 additions and 1 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,2 @@
with (sys) as f:
print(f)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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):

View File

@@ -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'