]> granicus.if.org Git - python/commitdiff
Only treat an AugAssign as def if its the target is a Name.
authorJeremy Hylton <jeremy@alum.mit.edu>
Thu, 12 Apr 2001 07:06:25 +0000 (07:06 +0000)
committerJeremy Hylton <jeremy@alum.mit.edu>
Thu, 12 Apr 2001 07:06:25 +0000 (07:06 +0000)
Fixes last bug found with test_scope.py.

Lib/compiler/symbols.py
Tools/compiler/compiler/symbols.py

index cde937b75355119c7bc291187bbdd2cedb3e7975..6d834e0c1d1ef75a00f18c8cdecda65041c5edd1 100644 (file)
@@ -299,9 +299,11 @@ class SymbolVisitor:
         scope.add_def(node.name)
 
     def visitAugAssign(self, node, scope):
-        # basically, the node is referenced and defined by the same expr
+        # If the LHS is a name, then this counts as assignment.
+        # Otherwise, it's just use.
         self.visit(node.node, scope)
-        self.visit(node.node, scope, 1)
+        if isinstance(node.node, ast.Name):
+            self.visit(node.node, scope, 1) # XXX worry about this
         self.visit(node.expr, scope)
 
     def visitAssign(self, node, scope):
index cde937b75355119c7bc291187bbdd2cedb3e7975..6d834e0c1d1ef75a00f18c8cdecda65041c5edd1 100644 (file)
@@ -299,9 +299,11 @@ class SymbolVisitor:
         scope.add_def(node.name)
 
     def visitAugAssign(self, node, scope):
-        # basically, the node is referenced and defined by the same expr
+        # If the LHS is a name, then this counts as assignment.
+        # Otherwise, it's just use.
         self.visit(node.node, scope)
-        self.visit(node.node, scope, 1)
+        if isinstance(node.node, ast.Name):
+            self.visit(node.node, scope, 1) # XXX worry about this
         self.visit(node.expr, scope)
 
     def visitAssign(self, node, scope):