aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_dict.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_dict.py b/Lib/test/test_dict.py
index e5dba7cdc57..4030716efb5 100644
--- a/Lib/test/test_dict.py
+++ b/Lib/test/test_dict.py
@@ -1476,6 +1476,24 @@ class DictTest(unittest.TestCase):
gc.collect()
self.assertTrue(gc.is_tracked(next(it)))
+ def test_store_evilattr(self):
+ class EvilAttr:
+ def __init__(self, d):
+ self.d = d
+
+ def __del__(self):
+ if 'attr' in self.d:
+ del self.d['attr']
+ gc.collect()
+
+ class Obj:
+ pass
+
+ obj = Obj()
+ obj.__dict__ = {}
+ for _ in range(10):
+ obj.attr = EvilAttr(obj.__dict__)
+
def test_str_nonstr(self):
# cpython uses a different lookup function if the dict only contains
# `str` keys. Make sure the unoptimized path is used when a non-`str`