mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
bpo-40116: dict: Add regression test for iteration order. (GH-31550)
This commit is contained in:
parent
a8c87a239e
commit
4f74052b45
3 changed files with 20 additions and 1 deletions
|
@ -1077,6 +1077,23 @@ class DictTest(unittest.TestCase):
|
|||
self.assertEqual(list(a), ['x', 'y'])
|
||||
self.assertEqual(list(b), ['x', 'y', 'z'])
|
||||
|
||||
@support.cpython_only
|
||||
def test_splittable_update(self):
|
||||
"""dict.update(other) must preserve order in other."""
|
||||
class C:
|
||||
def __init__(self, order):
|
||||
if order:
|
||||
self.a, self.b, self.c = 1, 2, 3
|
||||
else:
|
||||
self.c, self.b, self.a = 1, 2, 3
|
||||
o = C(True)
|
||||
o = C(False) # o.__dict__ has reversed order.
|
||||
self.assertEqual(list(o.__dict__), ["c", "b", "a"])
|
||||
|
||||
d = {}
|
||||
d.update(o.__dict__)
|
||||
self.assertEqual(list(d), ["c", "b", "a"])
|
||||
|
||||
def test_iterator_pickling(self):
|
||||
for proto in range(pickle.HIGHEST_PROTOCOL + 1):
|
||||
data = {1:"a", 2:"b", 3:"c"}
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
Fix regression that dict.update(other) may don't respect iterate order of
|
||||
other when other is key sharing dict.
|
|
@ -1 +1 @@
|
|||
In :func:`typing.get_type_hints`, support evaluating stringified ``ParamSpecArgs`` and ``ParamSpecKwargs`` annotations. Patch by Gregory Beauregard.
|
||||
In :func:`typing.get_type_hints`, support evaluating stringified ``ParamSpecArgs`` and ``ParamSpecKwargs`` annotations. Patch by Gregory Beauregard.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue