[issue27275] KeyError thrown by optimised collections.OrderedDict.popitem()

2016-06-08 Thread William Pitcock

New submission from William Pitcock:

The C-based optimised version of collections.OrderedDict occasionally throws 
KeyErrors when deleting items.

See https://github.com/mailgun/expiringdict/issues/16 for an example of this 
regression.

Backporting 3.6's patches to 3.5.1 does not resolve the issue. :(

--
components: Library (Lib)
messages: 267957
nosy: kaniini
priority: normal
severity: normal
status: open
title: KeyError thrown by optimised collections.OrderedDict.popitem()
type: behavior
versions: Python 3.5, Python 3.6

___
Python tracker 
<http://bugs.python.org/issue27275>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27275] KeyError thrown by optimised collections.OrderedDict.popitem()

2016-06-09 Thread William Pitcock

William Pitcock added the comment:

A frequent reproducer is to run the expiringdict tests on Python 3.5.1, 
unfortunately I cannot come up with a testcase.

Replacing use of popitem() with "del self[next(OrderedDict.__iter__(self))]" 
removes the KeyErrors and the structure otherwise works fine.

--

___
Python tracker 
<http://bugs.python.org/issue27275>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27275] KeyError thrown by optimised collections.OrderedDict.popitem()

2016-06-10 Thread William Pitcock

William Pitcock added the comment:

At least in my case, the application is single-threaded.  I don't think this is 
a locking-related issue as the expiringdict test case itself fails which is 
also single-threaded.

--

___
Python tracker 
<http://bugs.python.org/issue27275>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27275] KeyError thrown by optimised collections.OrderedDict.popitem()

2016-06-10 Thread William Pitcock

William Pitcock added the comment:

It seems to me that calling __contains__() (PySequence_Contains()) isn't 
necessary, as the first and last elements of the list are already known, and 
therefore known to be in the list.  Revising the behaviour of popitem() to 
avoid calling _odict_popkey_hash() seems like it may provide a marginal 
performance benefit as well as fix the problem.  Calling PyObject_DelItem() 
directly on the node should work fine I believe.

--

___
Python tracker 
<http://bugs.python.org/issue27275>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com