bpo-44206: Make sure that dict-keys's version is set to zero when value is popped (GH-27542)

This commit is contained in:
Mark Shannon 2021-08-02 14:54:23 +01:00 committed by GitHub
parent 626d397cc1
commit e06ae75e16
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View file

@ -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.