You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-02 16:44:46 +08:00
3.7 and 3.8 chained compare fixups
This commit is contained in:
@@ -263,8 +263,8 @@ check-bytecode-3.5:
|
||||
|
||||
#: Check deparsing Python 3.6
|
||||
check-bytecode-3.6:
|
||||
$(PYTHON) test_pythonlib.py --bytecode-3.6 --weak-verify
|
||||
$(PYTHON) test_pythonlib.py --bytecode-3.6-run --verify-run
|
||||
$(PYTHON) test_pythonlib.py --bytecode-3.6 --weak-verify
|
||||
|
||||
#: Check deparsing Python 3.7
|
||||
check-bytecode-3.7:
|
||||
@@ -272,6 +272,7 @@ check-bytecode-3.7:
|
||||
|
||||
#: Check deparsing Python 3.8
|
||||
check-bytecode-3.8:
|
||||
$(PYTHON) test_pythonlib.py --bytecode-3.8-run --verify-run
|
||||
$(PYTHON) test_pythonlib.py --bytecode-3.8 --weak-verify
|
||||
|
||||
#: short tests for bytecodes only for this version of Python
|
||||
|
BIN
test/bytecode_3.8_run/00_chained-compare.pyc
Normal file
BIN
test/bytecode_3.8_run/00_chained-compare.pyc
Normal file
Binary file not shown.
@@ -83,15 +83,29 @@ class Python37Parser(Python36Parser):
|
||||
call ::= expr CALL_METHOD_0
|
||||
|
||||
testtrue ::= compare_chained37
|
||||
testfalse ::= compare_chained37_false
|
||||
|
||||
|
||||
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 COME_FROM POP_JUMP_IF_FALSE JUMP_FORWARD ELSE
|
||||
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 POP_TOP JUMP_FORWARD COME_FROM
|
||||
compare_chained37_false ::= expr compare_chained1_false_37
|
||||
|
||||
compare_chained1a_37 ::= expr DUP_TOP ROT_THREE COMPARE_OP POP_JUMP_IF_FALSE
|
||||
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 POP_TOP JUMP_FORWARD COME_FROM
|
||||
|
||||
compare_chained1_false_37 ::= expr DUP_TOP ROT_THREE COMPARE_OP POP_JUMP_IF_FALSE
|
||||
compare_chained2c_37 POP_TOP JUMP_FORWARD COME_FROM
|
||||
|
||||
compare_chained2a_37 ::= expr COMPARE_OP POP_JUMP_IF_TRUE JUMP_FORWARD
|
||||
compare_chained2a_false_37 ::= expr COMPARE_OP POP_JUMP_IF_FALSE JUMP_FORWARD
|
||||
compare_chained2b_37 ::= expr COMPARE_OP COME_FROM POP_JUMP_IF_FALSE JUMP_FORWARD ELSE
|
||||
compare_chained2c_37 ::= expr DUP_TOP ROT_THREE COMPARE_OP come_from_opt POP_JUMP_IF_FALSE
|
||||
compare_chained2a_false_37 ELSE
|
||||
|
||||
_ifstmts_jump ::= c_stmts_opt come_froms
|
||||
"""
|
||||
|
||||
def customize_grammar_rules(self, tokens, customize):
|
||||
|
@@ -34,14 +34,22 @@ def customize_for_version37(self, version):
|
||||
'%|async for %c in %c:\n%+%c%-%-\n\n',
|
||||
(7, 'store'), (1, 'expr'), (16, 'for_block') ),
|
||||
'attribute37': ( '%c.%[1]{pattr}', 0 ),
|
||||
'compare_chained1a_37': ( ' %[3]{pattr.replace("-", " ")} %p %p',
|
||||
(0, 19),
|
||||
(-4, 19)),
|
||||
'compare_chained1b_37': ( ' %[3]{pattr.replace("-", " ")} %p %p',
|
||||
(0, 19),
|
||||
(-4, 19)),
|
||||
'compare_chained2a_37': ( '%[1]{pattr.replace("-", " ")} %p', (0, 19)),
|
||||
|
||||
'compare_chained2b_37': ( '%[1]{pattr.replace("-", " ")} %p', (0, 19)),
|
||||
'compare_chained1a_37': (
|
||||
' %[3]{pattr.replace("-", " ")} %p %p',
|
||||
(0, 19), (-4, 19)),
|
||||
'compare_chained1_false_37': (
|
||||
' %[3]{pattr.replace("-", " ")} %p %p',
|
||||
(0, 19), (-4, 19)),
|
||||
'compare_chained1b_37': (
|
||||
' %[3]{pattr.replace("-", " ")} %p %p',
|
||||
(0, 19), (-4, 19)),
|
||||
'compare_chained2a_37': (
|
||||
'%[1]{pattr.replace("-", " ")} %p',
|
||||
(0, 19) ),
|
||||
'compare_chained2a_false_37': (
|
||||
'%[1]{pattr.replace("-", " ")} %p',
|
||||
(0, 19 ) ),
|
||||
'compare_chained2c_37': (
|
||||
'%[3]{pattr.replace("-", " ")} %p %p', (0, 19), (6, 19) ),
|
||||
|
||||
})
|
||||
|
@@ -1837,7 +1837,11 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
typ = m.group('type') or '{'
|
||||
node = startnode
|
||||
if m.group('child'):
|
||||
node = node[int(m.group('child'))]
|
||||
try:
|
||||
node = node[int(m.group('child'))]
|
||||
except:
|
||||
from trepan.api import debug; debug()
|
||||
pass
|
||||
|
||||
if typ == '%': self.write('%')
|
||||
elif typ == '+':
|
||||
|
Reference in New Issue
Block a user