summaryrefslogtreecommitdiff
path: root/Lib/test/test_scope.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2013-04-30 09:41:40 -0400
committerBenjamin Peterson <benjamin@python.org>2013-04-30 09:41:40 -0400
commita2fc2ebe3d645e60d26996b51d8b33a1fe177d5c (patch)
tree1ea3e6bd538e2171a60e96ba1656a3457e129599 /Lib/test/test_scope.py
parentc6666f2ecc6dfd60aa6fe88950c5dfb2eb8d6687 (diff)
downloadcpython-a2fc2ebe3d645e60d26996b51d8b33a1fe177d5c.tar.gz
check local class namespace before reaching for cells (closes #17853)
Diffstat (limited to 'Lib/test/test_scope.py')
-rw-r--r--Lib/test/test_scope.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_scope.py b/Lib/test/test_scope.py
index 129a18aade..f4ed2442c6 100644
--- a/Lib/test/test_scope.py
+++ b/Lib/test/test_scope.py
@@ -714,6 +714,19 @@ class ScopeTests(unittest.TestCase):
global a
+ def testClassNamespaceOverridesClosure(self):
+ # See #17853.
+ x = 42
+ class X:
+ locals()["x"] = 43
+ y = x
+ self.assertEqual(X.y, 43)
+ class X:
+ locals()["x"] = 43
+ del x
+ self.assertFalse(hasattr(X, "x"))
+ self.assertEqual(x, 42)
+
def test_main():
run_unittest(ScopeTests)