[issue19414] iter(ordered_dict) yields keys not in dict in some circumstances

2014-06-14 Thread Nikolaus Rath

Nikolaus Rath added the comment:

Raymond, it would be nice if you could respond to my last comment...

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19414
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19414] iter(ordered_dict) yields keys not in dict in some circumstances

2014-06-14 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Sorry Nikolaus, I'm happy with the code and docs as they are.  In general, you 
should assume that unless documented otherwise, any pure python container 
(stdlib or 3rd party) has undefined behavior if you mutate while iterating 
(like you should not assume thread-safety unless a container is documented as 
threadsafe).  At your behest, I added extra code to trigger an earlier and more 
visible failure in some circumstances, but that is the limit.  OrderedDicts 
have been around for a good while (not just the stdlib but also in other code 
predating the one in the stdlib), so we know that this hasn't been a problem in 
practice. 

Please declare victory, move on, and don't keep extending this closed thread.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19414
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19414] iter(ordered_dict) yields keys not in dict in some circumstances

2014-05-07 Thread Nikolaus Rath

Nikolaus Rath added the comment:

Raymond, I think your patch does not really address the issue reported here. 
The dict documentation still guarantees that mutating a dict during iteration 
will raise a RuntimeError or may skip elements. The OrderedDict documentation 
still does not point out that OrderedDicts behave differently, yet they still 
raise a different exception than a regular dict in the same situation.

I believe it should be possible to pass an OrderedDict to any function 
expecting a regular dict. This is still not possible. But even if you think 
this is not desirable (or not worth the cost), could we at least *document* 
that OrderedDicts behave differently?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19414
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19414] iter(ordered_dict) yields keys not in dict in some circumstances

2014-05-03 Thread Roundup Robot

Roundup Robot added the comment:

New changeset a3c345ba3563 by Raymond Hettinger in branch 'default':
Issue #19414: Have the OrderedDict mark deleted links as unusable.
http://hg.python.org/cpython/rev/a3c345ba3563

--
nosy: +python-dev

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19414
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19414] iter(ordered_dict) yields keys not in dict in some circumstances

2014-05-03 Thread Raymond Hettinger

Raymond Hettinger added the comment:

To address Armin's concern, I'm triggering an early failure by setting the link 
fields to None.  That will help prevent accidental reliance on non-guaranteed 
behaviors.

--
resolution:  - fixed
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19414
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19414] iter(ordered_dict) yields keys not in dict in some circumstances

2014-04-13 Thread Nikolaus Rath

Nikolaus Rath added the comment:

The patch applies cleanly to 3.4 and 3.5, not sure why the review link does not 
show up. I'm attaching the file again, maybe that helps.

--
Added file: http://bugs.python.org/file34804/issue19414_r2.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19414
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19414] iter(ordered_dict) yields keys not in dict in some circumstances

2014-04-12 Thread Chris Angelico

Chris Angelico added the comment:

I agree that current behaviour is a bit confusing; also, the implication is 
that deleting from the dictionary while you have an iterator may leave some 
hanging references around the place, which raises a red flag in my mind (maybe 
something else might find the stale data, too).

My inclination would be to Armin's idea of setting next to None. Seems simpler 
than trying too hard to patch around something that's a bad idea anyway.

--
nosy: +Rosuav

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19414
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19414] iter(ordered_dict) yields keys not in dict in some circumstances

2014-04-12 Thread Alexander Belopolsky

Changes by Alexander Belopolsky alexander.belopol...@gmail.com:


--
nosy: +belopolsky

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19414
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19414] iter(ordered_dict) yields keys not in dict in some circumstances

2014-01-07 Thread Nikolaus Rath

Nikolaus Rath added the comment:

I have attached a patch that fixes this issue. Looking at Raymonds  comments in 
issue 19332, I have kept new code out of the critical path in __iter__ and 
instead modified the __delitem__ method (I assume that an element is removed 
only once, but may be iterated over many times). The updated __delitem__ now 
also updates the prev and next links of the removed item itself. When the 
current item is removed during an iteration, the iteration thus stops.

I hope that's an acceptable solution.

--
keywords: +patch
Added file: http://bugs.python.org/file33359/issue19414.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19414
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19414] iter(ordered_dict) yields keys not in dict in some circumstances

2013-10-30 Thread Nikolaus Rath

Changes by Nikolaus Rath nikol...@rath.org:


--
title: OrderedDict.values() behavior for modified instance - 
iter(ordered_dict) yields keys not in dict in some circumstances

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19414
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com