You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Merge branch 'master' into python-2.4
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
PYTHON_VERSION=3.6.4
|
||||
PYTHON_VERSION=3.6.5
|
||||
|
||||
# FIXME put some of the below in a common routine
|
||||
function finish {
|
||||
|
BIN
test/bytecode_2.7/03_for_try_raise.pyc
Normal file
BIN
test/bytecode_2.7/03_for_try_raise.pyc
Normal file
Binary file not shown.
12
test/simple_source/bug27+/03_for_try_raise.py
Normal file
12
test/simple_source/bug27+/03_for_try_raise.py
Normal file
@@ -0,0 +1,12 @@
|
||||
# Code in 2.7 needing rule:
|
||||
# try_except ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK except_handler
|
||||
# Generally we need a COME_FROM. But not in the situation below.
|
||||
|
||||
for package in [1,2]:
|
||||
try:
|
||||
pass
|
||||
except IndexError:
|
||||
with __file__ as f:
|
||||
pass
|
||||
except:
|
||||
raise
|
@@ -56,6 +56,8 @@ case $PYVERSION in
|
||||
2.6)
|
||||
SKIP_TESTS=(
|
||||
[test_compile.py]=1 # Intermittent - sometimes works and sometimes doesn't
|
||||
[test_grammar.py]=1 # Need real flow control. "and" in side "or"
|
||||
# "and" inside ifelse need to simulatenously work
|
||||
[test_grp.py]=1 # Long test - might work Control flow?
|
||||
[test_opcodes.py]=1
|
||||
[test_pwd.py]=1 # Long test - might work? Control flow?
|
||||
|
@@ -323,6 +323,7 @@ class Python26Parser(Python2Parser):
|
||||
""")
|
||||
super(Python26Parser, self).customize_grammar_rules(tokens, customize)
|
||||
self.check_reduce['and'] = 'AST'
|
||||
self.check_reduce['assert_expr_and'] = 'AST'
|
||||
self.check_reduce['list_for'] = 'AST'
|
||||
self.check_reduce['try_except'] = 'tokens'
|
||||
self.check_reduce['tryelsestmt'] = 'AST'
|
||||
@@ -333,12 +334,20 @@ class Python26Parser(Python2Parser):
|
||||
tokens, first, last)
|
||||
if invalid or tokens is None:
|
||||
return invalid
|
||||
if rule == ('and', ('expr', 'jmp_false', 'expr', '\\e_come_from_opt')):
|
||||
if rule in (
|
||||
('and', ('expr', 'jmp_false', 'expr', '\\e_come_from_opt')),
|
||||
('and', ('expr', 'jmp_false', 'expr', 'come_from_opt')),
|
||||
('assert_expr_and', ('assert_expr', 'jmp_false', 'expr'))
|
||||
):
|
||||
|
||||
# FIXME: workaround profiling bug
|
||||
if ast[1] is None:
|
||||
return False
|
||||
|
||||
# For now, we won't let the 2nd 'expr' be a "conditional_not"
|
||||
if ast[2][0] == 'conditional_not':
|
||||
return True
|
||||
|
||||
# Test that jmp_false jumps to the end of "and"
|
||||
# or that it jumps to the same place as the end of "and"
|
||||
jmp_false = ast[1][0]
|
||||
|
@@ -51,6 +51,10 @@ class Python27Parser(Python2Parser):
|
||||
|
||||
def p_try27(self, args):
|
||||
"""
|
||||
# If the last except is a "raise" we might not have a final COME_FROM
|
||||
try_except ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
||||
except_handler
|
||||
|
||||
tryfinallystmt ::= SETUP_FINALLY suite_stmts_opt
|
||||
POP_BLOCK LOAD_CONST
|
||||
COME_FROM_FINALLY suite_stmts_opt END_FINALLY
|
||||
@@ -143,6 +147,9 @@ class Python27Parser(Python2Parser):
|
||||
# 2.7.5 (and before to 2.7.0?)
|
||||
while1stmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK COME_FROM
|
||||
while1stmt ::= SETUP_LOOP l_stmts_opt CONTINUE COME_FROM
|
||||
while1stmt ::= SETUP_LOOP returns COME_FROM
|
||||
while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK
|
||||
else_suitel COME_FROM
|
||||
|
||||
while1stmt ::= SETUP_LOOP returns bp_come_from
|
||||
while1stmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_BLOCK COME_FROM
|
||||
|
@@ -1632,12 +1632,14 @@ class FragmentsWalker(pysource.SourceWalker, object):
|
||||
index = entry[arg]
|
||||
if isinstance(index, tuple):
|
||||
assert node[index[0]] == index[1], (
|
||||
"at %s[%d], %s vs %s" % (
|
||||
"at %s[%d], expected %s node; got %s" % (
|
||||
node.kind, arg, node[index[0]].kind, index[1])
|
||||
)
|
||||
index = index[0]
|
||||
if isinstance(index, int):
|
||||
self.preorder(node[index])
|
||||
assert isinstance(index, int), (
|
||||
"at %s[%d], %s should be int or tuple" % (
|
||||
node.kind, arg, type(index)))
|
||||
self.preorder(node[index])
|
||||
|
||||
finish = len(self.f.getvalue())
|
||||
self.set_pos_info(node, start, finish)
|
||||
|
@@ -1744,12 +1744,15 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
index = entry[arg]
|
||||
if isinstance(index, tuple):
|
||||
assert node[index[0]] == index[1], (
|
||||
"at %s[%d], %s vs %s" % (
|
||||
"at %s[%d], expected %s node; got %s" % (
|
||||
node.kind, arg, node[index[0]].kind, index[1])
|
||||
)
|
||||
index = index[0]
|
||||
if isinstance(index, int):
|
||||
self.preorder(node[index])
|
||||
assert isinstance(index, int), (
|
||||
"at %s[%d], %s should be int or tuple" % (
|
||||
node.kind, arg, type(index)))
|
||||
self.preorder(node[index])
|
||||
|
||||
arg += 1
|
||||
elif typ == 'p':
|
||||
p = self.prec
|
||||
|
Reference in New Issue
Block a user