diff --git a/test/bytecode_2.6/07_withstmt_fn.pyc b/test/bytecode_2.6/07_withstmt_fn.pyc new file mode 100644 index 00000000..a9d141d5 Binary files /dev/null and b/test/bytecode_2.6/07_withstmt_fn.pyc differ diff --git a/test/simple_source/stmts/07_withstmt_fn.py b/test/simple_source/stmts/07_withstmt_fn.py new file mode 100644 index 00000000..03a26247 --- /dev/null +++ b/test/simple_source/stmts/07_withstmt_fn.py @@ -0,0 +1,11 @@ +# Python 2.6 has a truly weird way of handling with here. +# added rule for 2.6 +# setupwith ::= DUP_TOP LOAD_ATTR ROT_TWO LOAD_ATTR CALL_FUNCTION_0 POP_TOP + +import sys +from warnings import catch_warnings +with catch_warnings(): + if sys.py3kwarning: + sys.filterwarnings("ignore", ".*mimetools has been removed", + DeprecationWarning) + import mimetools diff --git a/uncompyle6/parsers/parse26.py b/uncompyle6/parsers/parse26.py index aef40cb2..123bc5a5 100644 --- a/uncompyle6/parsers/parse26.py +++ b/uncompyle6/parsers/parse26.py @@ -85,6 +85,15 @@ class Python26Parser(Python2Parser): """ assert ::= assert_expr jmp_true LOAD_ASSERT RAISE_VARARGS_1 come_from_pop ifelsestmt ::= testexpr c_stmts_opt jf_pop else_suite COME_FROM + + # This rule is contorted a little to make sutie_stmts_opt be the + # forth argument for the semantic routines. + withstmt ::= expr setupwith SETUP_FINALLY suite_stmts_opt + POP_BLOCK LOAD_CONST COME_FROM WITH_CLEANUP END_FINALLY + + # This is truly weird. 2.7 does this (not including POP_TOP) with + # opcode SETUP_WITH + setupwith ::= DUP_TOP LOAD_ATTR ROT_TWO LOAD_ATTR CALL_FUNCTION_0 POP_TOP """ def p_comp26(self, args):