You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
3.7+ "or" handling in listcomp
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -23,6 +23,17 @@ def columnize(l):
|
||||
if not isinstance(l[i], str)]
|
||||
assert [0, 2] == columnize([1, 'a', 2])
|
||||
|
||||
# From 3.7.6 _collections_abc.py
|
||||
# Bug was handling "or" in listcomp
|
||||
def count(values, x):
|
||||
return sum(1 for v in values if v or x)
|
||||
|
||||
assert count([2, 2], False) == 2
|
||||
assert count([], False) == 0
|
||||
assert count([], True) == 0
|
||||
assert count([2], True) == 1
|
||||
assert count([0], False) == 0
|
||||
|
||||
# From 3.7 test_generators
|
||||
# Bug was in handling the way list_if is optimized in 3.7+;
|
||||
# We need list_if37 and compare_chained37.
|
||||
|
@@ -641,6 +641,9 @@ class Python37Parser(Python37BaseParser):
|
||||
expr ::= if_exp_37b
|
||||
if_exp_37a ::= and_not expr JUMP_FORWARD come_froms expr COME_FROM
|
||||
if_exp_37b ::= expr jmp_false expr POP_JUMP_IF_FALSE jump_forward_else expr
|
||||
or ::= expr jmp_true expr
|
||||
jmp_false_cf ::= POP_JUMP_IF_FALSE COME_FROM
|
||||
comp_if ::= or jmp_false_cf comp_iter
|
||||
"""
|
||||
|
||||
def p_comprehension3(self, args):
|
||||
|
Reference in New Issue
Block a user