[Python-checkins] gh-94808: Improve coverage of dictresize (GH-100619)
methane
webhook-mailer at python.org
Sat Dec 31 04:15:35 EST 2022
https://github.com/python/cpython/commit/636e9dd23f88c701eecf91156835fe0fc8b1feb6
commit: 636e9dd23f88c701eecf91156835fe0fc8b1feb6
branch: main
author: tqxia <44689929+tqxia at users.noreply.github.com>
committer: methane <songofacandy at gmail.com>
date: 2022-12-31T18:15:30+09:00
summary:
gh-94808: Improve coverage of dictresize (GH-100619)
files:
M Lib/test/test_dict.py
diff --git a/Lib/test/test_dict.py b/Lib/test/test_dict.py
index 5b8baaf9e6e2..79638340059f 100644
--- a/Lib/test/test_dict.py
+++ b/Lib/test/test_dict.py
@@ -1094,6 +1094,21 @@ def __init__(self, order):
d.update(o.__dict__)
self.assertEqual(list(d), ["c", "b", "a"])
+ @support.cpython_only
+ def test_splittable_to_generic_combinedtable(self):
+ """split table must be correctly resized and converted to generic combined table"""
+ class C:
+ pass
+
+ a = C()
+ a.x = 1
+ d = a.__dict__
+ before_resize = sys.getsizeof(d)
+ d[2] = 2 # split table is resized to a generic combined table
+
+ self.assertGreater(sys.getsizeof(d), before_resize)
+ self.assertEqual(list(d), ['x', 2])
+
def test_iterator_pickling(self):
for proto in range(pickle.HIGHEST_PROTOCOL + 1):
data = {1:"a", 2:"b", 3:"c"}
More information about the Python-checkins
mailing list