summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_module.py
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2021-08-02 13:54:23 (GMT)
committerGitHub <noreply@github.com>2021-08-02 13:54:23 (GMT)
commite06ae75e16dbf46b6626b6a41b62391ea1fdb319 (patch)
tree1d4af7306909cd560644a16786b2177d86ebc3c4 /Lib/test/test_module.py
parent626d397cc1612ea5eef153dd910834c2ee00ddbd (diff)
downloadcpython-e06ae75e16dbf46b6626b6a41b62391ea1fdb319.zip
cpython-e06ae75e16dbf46b6626b6a41b62391ea1fdb319.tar.gz
cpython-e06ae75e16dbf46b6626b6a41b62391ea1fdb319.tar.bz2
bpo-44206: Make sure that dict-keys's version is set to zero when value is popped (GH-27542)
Diffstat (limited to 'Lib/test/test_module.py')
-rw-r--r--Lib/test/test_module.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_module.py b/Lib/test/test_module.py
index 6608dbc..619348e 100644
--- a/Lib/test/test_module.py
+++ b/Lib/test/test_module.py
@@ -332,6 +332,18 @@ a = A(destroyed)"""
self.assertFalse("__annotations__" in ann_module4.__dict__)
+ def test_repeated_attribute_pops(self):
+ # Repeated accesses to module attribute will be specialized
+ # Check that popping the attribute doesn't break it
+ m = ModuleType("test")
+ d = m.__dict__
+ count = 0
+ for _ in range(100):
+ m.attr = 1
+ count += m.attr # Might be specialized
+ d.pop("attr")
+ self.assertEqual(count, 100)
+
# frozen and namespace module reprs are tested in importlib.