Merge branch 'master' into python-2.4

This commit is contained in:
rocky
2018-06-23 05:48:49 -04:00
5 changed files with 26 additions and 5 deletions

View File

@@ -46,11 +46,11 @@ def test_grammar():
unused_rhs.add("mkfunc_annotate")
unused_rhs.add("dict_comp")
unused_rhs.add("classdefdeco1")
if PYTHON_VERSION in (3.5, 3.6, 3.7):
if PYTHON_VERSION >= 3.5:
expect_right_recursive.add((('l_stmts',
('lastl_stmt', 'come_froms', 'l_stmts'))))
pass
else:
elif 3.0 < PYTHON_VERSION < 3.3:
expect_right_recursive.add((('l_stmts',
('lastl_stmt', 'COME_FROM', 'l_stmts'))))
pass

Binary file not shown.

View File

@@ -0,0 +1,9 @@
# From 3.0.1/lib/python3.0/_dummy_thread.py
def start_new_thread(function, args, kwargs={}):
try:
function()
except SystemExit:
pass
except:
args()

View File

@@ -64,11 +64,12 @@ class Python30Parser(Python31Parser):
comp_iter ::= expr expr SET_ADD
comp_iter ::= expr expr LIST_APPEND
jump_forward_else ::= JUMP_FORWARD POP_TOP
jump_absolute_else ::= JUMP_ABSOLUTE POP_TOP
except_suite ::= c_stmts POP_EXCEPT jump_except POP_TOP
jump_forward_else ::= JUMP_FORWARD POP_TOP
jump_absolute_else ::= JUMP_ABSOLUTE POP_TOP
except_suite ::= c_stmts POP_EXCEPT jump_except POP_TOP
except_suite_finalize ::= SETUP_FINALLY c_stmts_opt except_var_finalize END_FINALLY
_jump POP_TOP
jump_except ::= JUMP_FORWARD POP_TOP
# In many ways 3.0 is like 2.6. The below rules in fact are the same or similar.
@@ -83,6 +84,8 @@ class Python30Parser(Python31Parser):
and ::= expr JUMP_IF_FALSE POP_TOP expr COME_FROM
whilestmt ::= SETUP_LOOP testexpr l_stmts_opt
JUMP_BACK POP_TOP POP_BLOCK COME_FROM_LOOP
whilestmt ::= SETUP_LOOP testexpr returns
POP_TOP POP_BLOCK COME_FROM_LOOP
"""
def customize_grammar_rules(self, tokens, customize):
@@ -96,6 +99,8 @@ class Python30Parser(Python31Parser):
jump_absolute_else ::= JUMP_ABSOLUTE ELSE
whilestmt ::= SETUP_LOOP testexpr l_stmts_opt COME_FROM JUMP_BACK POP_BLOCK
COME_FROM_LOOP
whilestmt ::= SETUP_LOOP testexpr returns
POP_BLOCK COME_FROM_LOOP
assert ::= assert_expr jmp_true LOAD_ASSERT RAISE_VARARGS_1
return_if_lambda ::= RETURN_END_IF_LAMBDA
compare_chained1 ::= expr DUP_TOP ROT_THREE COMPARE_OP JUMP_IF_FALSE_OR_POP compare_chained2 COME_FROM

View File

@@ -317,6 +317,13 @@ class Scanner30(Scanner3):
pass
pass
if code[pre_rtarget] == self.opc.RETURN_VALUE:
if self.version == 3.0:
next_op = rtarget
if code[next_op] == self.opc.POP_TOP:
next_op = rtarget
next_op += instruction_size(self.code[next_op], self.opc)
if code[next_op] == self.opc.POP_BLOCK:
return
self.return_end_ifs.add(pre_rtarget)
else:
self.fixed_jumps[offset] = rtarget