Skip to content

Commit 618f930

Browse files
committed
gh-147957: pop items from UserDict in LIFO order
`UserDict.popitem` used to pop first-in, first-out since that's the `MutableMapping` implementation. It now pops first-in, last-out since that's the behavior guaranteed for `dict` starting in Python 3.7.
1 parent dea4083 commit 618f930

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Lib/collections/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,6 +1253,13 @@ def copy(self):
12531253
c.update(self)
12541254
return c
12551255

1256+
1257+
# This method has a default implementation in MutableMapping, but dict's
1258+
# equivalent is first-in, first-out.
1259+
def popitem(self):
1260+
return self.data.popitem()
1261+
1262+
12561263
@classmethod
12571264
def fromkeys(cls, iterable, value=None):
12581265
d = cls()

0 commit comments

Comments
 (0)