You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
In 2.7: raise <expr>; expr can't be a "or"
This commit is contained in:
BIN
test/bytecode_2.7_run/02_assert.pyc
Normal file
BIN
test/bytecode_2.7_run/02_assert.pyc
Normal file
Binary file not shown.
9
test/simple_source/bug27+/02_assert.py
Normal file
9
test/simple_source/bug27+/02_assert.py
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# From 2.7 test_argparse.py
|
||||||
|
# Bug was turnning assert into an "or raise" statement
|
||||||
|
def __call__(arg, dest):
|
||||||
|
try:
|
||||||
|
assert arg == 'spam', 'dest: %s' % dest
|
||||||
|
except:
|
||||||
|
raise
|
||||||
|
|
||||||
|
__call__('spam', __file__)
|
@@ -175,6 +175,7 @@ class Python27Parser(Python2Parser):
|
|||||||
""")
|
""")
|
||||||
super(Python27Parser, self).customize_grammar_rules(tokens, customize)
|
super(Python27Parser, self).customize_grammar_rules(tokens, customize)
|
||||||
self.check_reduce['and'] = 'AST'
|
self.check_reduce['and'] = 'AST'
|
||||||
|
self.check_reduce['raise_stmt1'] = 'AST'
|
||||||
# self.check_reduce['conditional_true'] = 'AST'
|
# self.check_reduce['conditional_true'] = 'AST'
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -191,6 +192,8 @@ class Python27Parser(Python2Parser):
|
|||||||
jmp_target = jmp_false.offset + jmp_false.attr + 3
|
jmp_target = jmp_false.offset + jmp_false.attr + 3
|
||||||
return not (jmp_target == tokens[last].offset or
|
return not (jmp_target == tokens[last].offset or
|
||||||
tokens[last].pattr == jmp_false.pattr)
|
tokens[last].pattr == jmp_false.pattr)
|
||||||
|
elif rule[0] == ('raise_stmt1'):
|
||||||
|
return ast[0] == 'expr' and ast[0][0] == 'or'
|
||||||
# elif rule[0] == ('conditional_true'):
|
# elif rule[0] == ('conditional_true'):
|
||||||
# # FIXME: the below is a hack: we check expr for
|
# # FIXME: the below is a hack: we check expr for
|
||||||
# # nodes that could have possibly been a been a Boolean.
|
# # nodes that could have possibly been a been a Boolean.
|
||||||
|
Reference in New Issue
Block a user