Skip to content

Commit 4394d46

Browse files
committed
Remove redundant list_comp() fn
1 parent b10dd0e commit 4394d46

File tree

3 files changed

+13
-77
lines changed

3 files changed

+13
-77
lines changed

test/simple_source/bug26/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/.python-version

test/stdlib/2.4-exclude.sh

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,14 @@ SKIP_TESTS=(
3838
[test_winreg.py]=1 # it fails on its own
3939
[test_winsound.py]=1 # it fails on its own
4040
[test_zlib.py]=1 # it fails on its own
41-
42-
[test_decimal.py]=1 #
41+
[test_decimal.py]=1 # fails on its own - no module named test_support
4342
[test_dis.py]=1 # We change line numbers - duh!
44-
[test_generators.py]=1 # Investigate
43+
[test_generators.py]=1 # fails on its own - no module named test_support
4544
# [test_grammar.py]=1 # fails on its own - no module tests.test_support
4645
[test_grp.py]=1 # Long test - might work Control flow?
47-
[test_pep247.py]=1 # Long test - might work? Control flow?
4846
[test_socketserver.py]=1 # -- test takes too long to run: 40 seconds
4947
[test_threading.py]=1 # test takes too long to run: 11 seconds
5048
[test_thread.py]=1 # test takes too long to run: 36 seconds
5149
[test_trace.py]=1 # Long test - works
52-
[test_zipfile64.py]=1 # Runs ok but takes 204 seconds
5350
)
5451
# About 243 files, 0 in 19 minutes

uncompyle6/semantics/n_actions.py

Lines changed: 10 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -926,66 +926,18 @@ def n_list(self, node: SyntaxTree):
926926
n_set = n_build_set = n_tuple = n_list
927927

928928
def n_list_comp(self, node):
929-
"""List comprehensions"""
930-
p = self.prec
931-
self.prec = 100
932-
if self.version >= (2, 7):
933-
if self.is_pypy:
934-
self.n_list_comp_pypy27(node)
935-
return
936-
n = node[-1]
937-
elif node[-1] == "delete":
938-
if node[-2] == "JUMP_BACK":
939-
n = node[-3]
940-
else:
941-
n = node[-2]
942-
943-
assert n == "list_iter"
944-
945-
# Find the list comprehension body. It is the inner-most
946-
# node that is not list_.. .
947-
# FIXME: DRY with other use
948-
while n == "list_iter":
949-
n = n[0] # iterate one nesting deeper
950-
if n == "list_for":
951-
n = n[3]
952-
elif n == "list_if":
953-
n = n[2]
954-
elif n == "list_if_not":
955-
n = n[2]
956-
assert n == "lc_body"
957-
self.write("[ ")
958-
959-
if self.version >= (2, 7):
960-
expr = n[0]
961-
list_iter = node[-1]
929+
self.write("[")
930+
if node[0].kind == "load_closure":
931+
assert self.version >= (3, 0)
932+
self.listcomp_closure3(node)
962933
else:
963-
expr = n[1]
964-
if node[-2] == "JUMP_BACK":
965-
list_iter = node[-3]
934+
if node == "listcomp_async":
935+
list_iter_index = 5
966936
else:
967-
list_iter = node[-2]
968-
969-
assert expr == "expr"
970-
assert list_iter == "list_iter"
971-
972-
# FIXME: use source line numbers for directing line breaks
973-
974-
line_number = self.line_number
975-
last_line = self.f.getvalue().split("\n")[-1]
976-
l = len(last_line)
977-
indent = " " * (l - 1)
978-
979-
self.preorder(expr)
980-
line_number = self.indent_if_source_nl(line_number, indent)
981-
self.preorder(list_iter)
982-
l2 = self.indent_if_source_nl(line_number, indent)
983-
if l2 != line_number:
984-
self.write(" " * (len(indent) - len(self.indent) - 1) + "]")
985-
else:
986-
self.write(" ]")
987-
self.prec = p
988-
self.prune() # stop recursing
937+
list_iter_index = 1
938+
self.comprehension_walk_newer(node, list_iter_index, 0)
939+
self.write("]")
940+
self.prune()
989941

990942
def n_list_comp_pypy27(self, node):
991943
"""List comprehensions in PYPY."""
@@ -1036,20 +988,6 @@ def n_list_comp_pypy27(self, node):
1036988
self.prec = p
1037989
self.prune() # stop recursing
1038990

1039-
def n_list_comp(self, node):
1040-
self.write("[")
1041-
if node[0].kind == "load_closure":
1042-
assert self.version >= (3, 0)
1043-
self.listcomp_closure3(node)
1044-
else:
1045-
if node == "listcomp_async":
1046-
list_iter_index = 5
1047-
else:
1048-
list_iter_index = 1
1049-
self.comprehension_walk_newer(node, list_iter_index, 0)
1050-
self.write("]")
1051-
self.prune()
1052-
1053991
def n_mkfunc(self, node):
1054992
code_node = find_code_node(node, -2)
1055993
code = code_node.attr

0 commit comments

Comments
 (0)