Xiang Zhang added the comment: Raymond, In single threaded case popitem may still fail.
I want to correct my last message that popitem does not fail in this case because it calls __getitem__ but instead it calls __contains__[1]. In __contains__ it deletes the item since it expires, and finally emit a KeyError[2]. Even if it passes __contains__, it will call __getitem__[3]. [1] https://hg.python.org/cpython/file/tip/Objects/odictobject.c#l1115 [2] https://hg.python.org/cpython/file/tip/Objects/odictobject.c#l1135 [3] https://hg.python.org/cpython/file/tip/Objects/odictobject.c#l1119 ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27275> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com