diff --git a/test/bytecode_2.5/06_if_and_bugs.pyc b/test/bytecode_2.5/06_if_and_bugs.pyc new file mode 100644 index 00000000..f3fb33e4 Binary files /dev/null and b/test/bytecode_2.5/06_if_and_bugs.pyc differ diff --git a/test/simple_source/bug25/06_if_and_bugs.py b/test/simple_source/bug25/06_if_and_bugs.py new file mode 100644 index 00000000..0dbd1636 --- /dev/null +++ b/test/simple_source/bug25/06_if_and_bugs.py @@ -0,0 +1,18 @@ +# 2.5 Bug is from nose/plugins/cover.py +def wantFile(self, file, package=None): + if self.coverInclusive: + if file.endswith(".py"): + if package and self.coverPackages: + for want in self.coverPackages: + if package.startswith(want): + return True + else: + return True + return None + + +# 2.5 bug is from nose/plugins/doctests.py +def wantFile2(self, file): + if self and (self.conf or [exc.search(file) for exc in self.conf]): + return True + return None diff --git a/uncompyle6/parsers/parse25.py b/uncompyle6/parsers/parse25.py index c9aebb0e..06bea5b8 100644 --- a/uncompyle6/parsers/parse25.py +++ b/uncompyle6/parsers/parse25.py @@ -62,6 +62,11 @@ class Python25Parser(Python26Parser): kv ::= DUP_TOP expr ROT_TWO expr STORE_SUBSCR _ifstmts_jump ::= c_stmts_opt COME_FROM JUMP_ABSOLUTE COME_FROM POP_TOP + + + # "and_then" is a hack around the fact we have THEN detection. + and_then ::= expr JUMP_IF_FALSE THEN POP_TOP expr JUMP_IF_FALSE THEN POP_TOP + testexpr_then ::= and_then """ def customize_grammar_rules(self, tokens, customize): diff --git a/uncompyle6/semantics/customize25.py b/uncompyle6/semantics/customize25.py index ee3a2d44..d3df25d2 100644 --- a/uncompyle6/semantics/customize25.py +++ b/uncompyle6/semantics/customize25.py @@ -33,6 +33,7 @@ def customize_for_version25(self, version): # Note: It is safe to put the variables after "as" in parenthesis, # and sometimes it is needed. "with": ("%|with %c:\n%+%c%-", 0, 3), + "and_then": ("%c and %c", (0, "expr"), (4, "expr")), } )