From c87710dd4b6caae8c05a4879bc73891f0bd29045 Mon Sep 17 00:00:00 2001 From: rocky Date: Mon, 26 Sep 2016 08:09:05 -0400 Subject: [PATCH] Python 3 COME_FROM -> COME_FROM_WITH appropriately --- pytest/test_grammar.py | 2 +- uncompyle6/parsers/parse3.py | 4 ++-- uncompyle6/parsers/parse35.py | 6 +++--- uncompyle6/scanners/controlflow.py | 2 -- uncompyle6/scanners/scanner3.py | 2 +- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/pytest/test_grammar.py b/pytest/test_grammar.py index 73dcfd95..d9d23a8b 100644 --- a/pytest/test_grammar.py +++ b/pytest/test_grammar.py @@ -33,7 +33,7 @@ def test_grammar(): ignore_set = set( """ JUMP_BACK CONTINUE RETURN_END_IF - COME_FROM COME_FROM_EXCEPT COME_FROM_LOOP + COME_FROM COME_FROM_EXCEPT COME_FROM_LOOP COME_FROM_WITH LOAD_GENEXPR LOAD_ASSERT LOAD_SETCOMP LOAD_DICTCOMP LAMBDA_MARKER RETURN_LAST """.split()) diff --git a/uncompyle6/parsers/parse3.py b/uncompyle6/parsers/parse3.py index f9963be0..e8b9589e 100644 --- a/uncompyle6/parsers/parse3.py +++ b/uncompyle6/parsers/parse3.py @@ -242,11 +242,11 @@ class Python3Parser(PythonParser): jmp_abs ::= JUMP_BACK withstmt ::= expr SETUP_WITH POP_TOP suite_stmts_opt - POP_BLOCK LOAD_CONST COME_FROM + POP_BLOCK LOAD_CONST COME_FROM_WITH WITH_CLEANUP END_FINALLY withasstmt ::= expr SETUP_WITH designator suite_stmts_opt - POP_BLOCK LOAD_CONST COME_FROM + POP_BLOCK LOAD_CONST COME_FROM_WITH WITH_CLEANUP END_FINALLY ''' diff --git a/uncompyle6/parsers/parse35.py b/uncompyle6/parsers/parse35.py index 8eb329e4..8d9bb1f8 100644 --- a/uncompyle6/parsers/parse35.py +++ b/uncompyle6/parsers/parse35.py @@ -19,15 +19,15 @@ class Python35Parser(Python3Parser): # Python 3.5+ has WITH_CLEANUP_START/FINISH withstmt ::= expr SETUP_WITH exprlist suite_stmts_opt - POP_BLOCK LOAD_CONST COME_FROM + POP_BLOCK LOAD_CONST COME_FROM_WITH WITH_CLEANUP_START WITH_CLEANUP_FINISH END_FINALLY withstmt ::= expr SETUP_WITH POP_TOP suite_stmts_opt - POP_BLOCK LOAD_CONST COME_FROM + POP_BLOCK LOAD_CONST COME_FROM_WITH WITH_CLEANUP_START WITH_CLEANUP_FINISH END_FINALLY withasstmt ::= expr SETUP_WITH designator suite_stmts_opt - POP_BLOCK LOAD_CONST COME_FROM + POP_BLOCK LOAD_CONST COME_FROM_WITH WITH_CLEANUP_START WITH_CLEANUP_FINISH END_FINALLY inplace_op ::= INPLACE_MATRIX_MULTIPLY diff --git a/uncompyle6/scanners/controlflow.py b/uncompyle6/scanners/controlflow.py index 266d5ee1..edb2e5e9 100644 --- a/uncompyle6/scanners/controlflow.py +++ b/uncompyle6/scanners/controlflow.py @@ -9,8 +9,6 @@ from xdis.bytecode import Bytecode control_flow_start = namedtuple('control_flow_start', ['name', 'type', 'offset']) control_flow_end = namedtuple('control_flow_end', ['name', 'type', 'offset']) -control_flow_pair = namedtuple('control_flow_pair', ['name', 'start_offset', 'end_offset']) - class ControlFlow(): def __init__(self, scanner): diff --git a/uncompyle6/scanners/scanner3.py b/uncompyle6/scanners/scanner3.py index 74a08050..a0fa43f0 100644 --- a/uncompyle6/scanners/scanner3.py +++ b/uncompyle6/scanners/scanner3.py @@ -206,7 +206,7 @@ class Scanner3(Scanner): # Adjust the grammar and remove the below and (self.opName(jump_offset)[len('SETUP_'):] == action.name) - and action.name in ['EXCEPT', 'LOOP']): + and action.name in ['EXCEPT', 'LOOP', 'WITH']): come_from_name = '%s_%s' % ( (come_from_name, action.name)) pass