summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_scope.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2013-04-30 13:41:40 (GMT)
committerBenjamin Peterson <benjamin@python.org>2013-04-30 13:41:40 (GMT)
commit3b0431dc6019d2f9ffa9adcaa78ddd3f7b76a2f5 (patch)
tree7f98ecba2e560776b91856eb74487c26c73d5d0d /Lib/test/test_scope.py
parentf256f5f3ebf6574a2708cfea36d857846893e71f (diff)
downloadcpython-3b0431dc6019d2f9ffa9adcaa78ddd3f7b76a2f5.zip
cpython-3b0431dc6019d2f9ffa9adcaa78ddd3f7b76a2f5.tar.gz
cpython-3b0431dc6019d2f9ffa9adcaa78ddd3f7b76a2f5.tar.bz2
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 129a18a..f4ed244 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)