You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-02 16:44:46 +08:00
@@ -64,10 +64,12 @@ check-3.5: check-bytecode
|
||||
#: Run working tests from Python 3.6
|
||||
check-3.6: check-bytecode
|
||||
$(PYTHON) test_pythonlib.py --bytecode-3.6 --weak-verify $(COMPILE)
|
||||
$(PYTHON) test_pythonlib.py --bytecode-3.6-run --verify-run
|
||||
|
||||
#: Run working tests from Python 3.7
|
||||
check-3.7: check-bytecode
|
||||
$(PYTHON) test_pythonlib.py --bytecode-3.7 --weak-verify $(COMPILE)
|
||||
$(PYTHON) test_pythonlib.py --bytecode-3.7-run --verify-run
|
||||
|
||||
# FIXME
|
||||
#: this is called when running under pypy3.5-5.8.0 or pypy2-5.6.0
|
||||
|
BIN
test/bytecode_3.7_run/01_chained_compare.pyc
Normal file
BIN
test/bytecode_3.7_run/01_chained_compare.pyc
Normal file
Binary file not shown.
19
test/simple_source/bug37/01_chained_compare.py
Normal file
19
test/simple_source/bug37/01_chained_compare.py
Normal file
@@ -0,0 +1,19 @@
|
||||
# From Python 3.7 pickle.py
|
||||
# Bug was different code generation for chained comparisons than prior Python versions
|
||||
|
||||
|
||||
def chained_compare_a(protocol):
|
||||
if not 0 <= protocol <= 7:
|
||||
raise ValueError("pickle protocol must be <= %d" % 7)
|
||||
|
||||
def chained_compare_b(a, obj):
|
||||
if a:
|
||||
if -0x80000000 <= obj <= 0x7fffffff:
|
||||
return 5
|
||||
|
||||
chained_compare_a(3)
|
||||
try:
|
||||
chained_compare_a(8)
|
||||
except ValueError:
|
||||
pass
|
||||
chained_compare_b(True, 0x0)
|
@@ -67,6 +67,17 @@ class Python37Parser(Python36Parser):
|
||||
|
||||
# FIXME: generalize and specialize
|
||||
call ::= expr CALL_METHOD_0
|
||||
|
||||
testtrue ::= compare_chained37
|
||||
|
||||
compare_chained37 ::= expr compare_chained1a_37
|
||||
compare_chained37 ::= expr compare_chained1b_37
|
||||
compare_chained2a_37 ::= expr COMPARE_OP POP_JUMP_IF_TRUE JUMP_FORWARD
|
||||
compare_chained2b_37 ::= expr COMPARE_OP POP_JUMP_IF_FALSE JUMP_FORWARD
|
||||
compare_chained1a_37 ::= expr DUP_TOP ROT_THREE COMPARE_OP POP_JUMP_IF_FALSE
|
||||
compare_chained2a_37 ELSE POP_TOP COME_FROM
|
||||
compare_chained1b_37 ::= expr DUP_TOP ROT_THREE COMPARE_OP POP_JUMP_IF_FALSE
|
||||
compare_chained2b_37 ELSE POP_TOP JUMP_FORWARD COME_FROM
|
||||
"""
|
||||
|
||||
def customize_grammar_rules(self, tokens, customize):
|
||||
|
@@ -917,6 +917,16 @@ def customize_for_version3(self, version):
|
||||
'async_for_stmt': (
|
||||
'%|async for %c in %c:\n%+%c%-%-\n\n',
|
||||
7, 1, 17),
|
||||
'compare_chained1a_37': ( ' %[3]{pattr.replace("-", " ")} %p %p',
|
||||
(0, 19),
|
||||
(-4, 19)),
|
||||
'compare_chained1b_37': ( ' %[3]{pattr.replace("-", " ")} %p %p',
|
||||
(0, 19),
|
||||
(-5, 19)),
|
||||
'compare_chained2a_37': ( '%[1]{pattr.replace("-", " ")} %p', (0, 19)),
|
||||
|
||||
'compare_chained2b_37': ( '%[1]{pattr.replace("-", " ")} %p', (0, 19)),
|
||||
|
||||
})
|
||||
pass
|
||||
pass # version >= 3.6
|
||||
|
Reference in New Issue
Block a user