Skip to content

Commit f030b33

Browse files
committed
Fix some 2.5 parsing bugs
1 parent 9450165 commit f030b33

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

test/bytecode_2.5/06_if_and_bugs.pyc

786 Bytes
Binary file not shown.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# 2.5 Bug is from nose/plugins/cover.py
2+
def wantFile(self, file, package=None):
3+
if self.coverInclusive:
4+
if file.endswith(".py"):
5+
if package and self.coverPackages:
6+
for want in self.coverPackages:
7+
if package.startswith(want):
8+
return True
9+
else:
10+
return True
11+
return None
12+
13+
14+
# 2.5 bug is from nose/plugins/doctests.py
15+
def wantFile2(self, file):
16+
if self and (self.conf or [exc.search(file) for exc in self.conf]):
17+
return True
18+
return None

uncompyle6/parsers/parse25.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ def p_misc25(self, args):
6262
kv ::= DUP_TOP expr ROT_TWO expr STORE_SUBSCR
6363
6464
_ifstmts_jump ::= c_stmts_opt COME_FROM JUMP_ABSOLUTE COME_FROM POP_TOP
65+
66+
67+
# "and_then" is a hack around the fact we have THEN detection.
68+
and_then ::= expr JUMP_IF_FALSE THEN POP_TOP expr JUMP_IF_FALSE THEN POP_TOP
69+
testexpr_then ::= and_then
6570
"""
6671

6772
def customize_grammar_rules(self, tokens, customize):

uncompyle6/semantics/customize25.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def customize_for_version25(self, version):
3333
# Note: It is safe to put the variables after "as" in parenthesis,
3434
# and sometimes it is needed.
3535
"with": ("%|with %c:\n%+%c%-", 0, 3),
36+
"and_then": ("%c and %c", (0, "expr"), (4, "expr")),
3637
}
3738
)
3839

0 commit comments

Comments
 (0)