You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 08:49:51 +08:00
Correct handling "if" in dictcomp in semantic actions for 3.x
This commit is contained in:
@@ -3,12 +3,24 @@
|
||||
#
|
||||
# This code is RUNNABLE!
|
||||
def x(s):
|
||||
return {k: v
|
||||
for (k, v) in s
|
||||
if not k.startswith('_')
|
||||
}
|
||||
return {k: v for (k, v) in s if not k.startswith("_")}
|
||||
|
||||
|
||||
# Yes, the print() is funny. This is
|
||||
# to test though a 2-arg assert where
|
||||
# the 2nd argument is not a string.
|
||||
assert x((('_foo', None),)) == {}, print("See issue #162")
|
||||
assert x((("_foo", None),)) == {}, print("See issue #162")
|
||||
|
||||
# From 3.7 test_dictcomps.py
|
||||
assert {k: v for k in range(10) for v in range(10) if k == v} == {
|
||||
0: 0,
|
||||
1: 1,
|
||||
2: 2,
|
||||
3: 3,
|
||||
4: 4,
|
||||
5: 5,
|
||||
6: 6,
|
||||
7: 7,
|
||||
8: 8,
|
||||
9: 9,
|
||||
}
|
||||
|
Reference in New Issue
Block a user