diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2001-09-17 19:33:48 (GMT) |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2001-09-17 19:33:48 (GMT) |
commit | 2e4cc7e0d84747826d3d2546d1bccd9c40a455c2 (patch) | |
tree | 7c9bcbb7414b9d94aee0ec20520a026bfdba17f4 /Tools/compiler | |
parent | c299fc16f2a8572780d2130ab9e55a6f22a93279 (diff) | |
download | cpython-2e4cc7e0d84747826d3d2546d1bccd9c40a455c2.zip cpython-2e4cc7e0d84747826d3d2546d1bccd9c40a455c2.tar.gz cpython-2e4cc7e0d84747826d3d2546d1bccd9c40a455c2.tar.bz2 |
Last set of change to get regression tests to pass
Remove the only test in the syntax module. It ends up that the
transformer must handle this error case.
In the transformer, check for a list compression in com_assign_list()
by looking for a list_for node where a comma is expected.
In pycodegen.compile() re-raise the SyntaxError rather than catching
it and exiting
Diffstat (limited to 'Tools/compiler')
-rw-r--r-- | Tools/compiler/compiler/pycodegen.py | 2 | ||||
-rw-r--r-- | Tools/compiler/compiler/syntax.py | 9 | ||||
-rw-r--r-- | Tools/compiler/compiler/transformer.py | 4 |
3 files changed, 10 insertions, 5 deletions
diff --git a/Tools/compiler/compiler/pycodegen.py b/Tools/compiler/compiler/pycodegen.py index 04c115a..7bc1795 100644 --- a/Tools/compiler/compiler/pycodegen.py +++ b/Tools/compiler/compiler/pycodegen.py @@ -49,7 +49,7 @@ def compile(filename, display=0): try: mod.compile(display) except SyntaxError, err: - print "SyntaxError:", err + raise else: f = open(filename + "c", "wb") mod.dump(f) diff --git a/Tools/compiler/compiler/syntax.py b/Tools/compiler/compiler/syntax.py index 14613ef..88c1453 100644 --- a/Tools/compiler/compiler/syntax.py +++ b/Tools/compiler/compiler/syntax.py @@ -39,7 +39,8 @@ class SyntaxErrorChecker: def visitAssign(self, node): # the transformer module handles many of these for target in node.nodes: - if isinstance(target, ast.AssList): - if target.lineno is None: - target.lineno = node.lineno - self.error(target, "can't assign to list comprehension") + pass +## if isinstance(target, ast.AssList): +## if target.lineno is None: +## target.lineno = node.lineno +## self.error(target, "can't assign to list comprehension") diff --git a/Tools/compiler/compiler/transformer.py b/Tools/compiler/compiler/transformer.py index 6e82b10..3607af1 100644 --- a/Tools/compiler/compiler/transformer.py +++ b/Tools/compiler/compiler/transformer.py @@ -943,6 +943,10 @@ class Transformer: def com_assign_list(self, node, assigning): assigns = [] for i in range(1, len(node), 2): + if i + 1 < len(node): + if node[i + 1][0] == symbol.list_for: + raise SyntaxError, "can't assign to list comprehension" + assert node[i + 1][0] == token.COMMA, node[i + 1] assigns.append(self.com_assign(node[i], assigning)) return AssList(assigns) |