diff options
author | ryneeverett <ryneeverett@gmail.com> | 2015-06-16 20:17:00 -0400 |
---|---|---|
committer | ryneeverett <ryneeverett@gmail.com> | 2015-06-16 20:17:00 -0400 |
commit | 6e3355389615bc6687048f3c9f877003b000905d (patch) | |
tree | 2a5988ba6252f326d0bae909a0e45debdb6aa7c0 | |
parent | 5c8ed3182a56989c317d07b4b8cd10270f4d6e89 (diff) | |
download | pyflakes-6e3355389615bc6687048f3c9f877003b000905d.tar.gz |
Fix TypeError bug.
The Binding.used property must be a tuple (unless it's False).
-rw-r--r-- | pyflakes/checker.py | 2 | ||||
-rw-r--r-- | pyflakes/test/test_other.py | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/pyflakes/checker.py b/pyflakes/checker.py index de7c6f8..fcdce9c 100644 --- a/pyflakes/checker.py +++ b/pyflakes/checker.py @@ -699,7 +699,7 @@ class Checker(object): global_scope.setdefault(node_name, node_value) # Bind name to non-global scopes, but as already "used". - node_value.used = True + node_value.used = (global_scope, node) for scope in self.scopeStack[global_scope_index + 1:]: scope[node_name] = node_value diff --git a/pyflakes/test/test_other.py b/pyflakes/test/test_other.py index 6e5950e..ac116c8 100644 --- a/pyflakes/test/test_other.py +++ b/pyflakes/test/test_other.py @@ -476,6 +476,15 @@ class Test(TestCase): foo.bar += foo.baz ''') + def test_globalDeclaredInDifferentScope(self): + """ + A 'global' can be declared in one scope and reused in another. + """ + self.flakes(''' + def f(): global foo + def g(): foo = 'anything'; foo.is_used() + ''') + class TestUnusedAssignment(TestCase): """ |