diff options
-rw-r--r-- | Lib/compiler/pycodegen.py | 2 | ||||
-rw-r--r-- | Lib/compiler/syntax.py | 9 | ||||
-rw-r--r-- | Lib/compiler/transformer.py | 4 | ||||
-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 |
6 files changed, 20 insertions, 10 deletions
diff --git a/Lib/compiler/pycodegen.py b/Lib/compiler/pycodegen.py index 04c115a..7bc1795 100644 --- a/Lib/compiler/pycodegen.py +++ b/Lib/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/Lib/compiler/syntax.py b/Lib/compiler/syntax.py index 14613ef..88c1453 100644 --- a/Lib/compiler/syntax.py +++ b/Lib/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/Lib/compiler/transformer.py b/Lib/compiler/transformer.py index 6e82b10..3607af1 100644 --- a/Lib/compiler/transformer.py +++ b/Lib/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) 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) |