[issue6017] Dict fails to notice addition and deletion of keys during iteration

2009-05-17 Thread Georg Brandl
Georg Brandl added the comment: OK, I now changed it to "may raise ... or fail to iterate over all entries" in r72708. -- ___ Python tracker ___ _

[issue6017] Dict fails to notice addition and deletion of keys during iteration

2009-05-16 Thread Terry J. Reedy
Terry J. Reedy added the comment: I would be happy enough to change 'will' to 'may'. There are a lot of undocumented exception-raising circumstances, and this one already be undocumented in Py3. -- ___ Python tracker

[issue6017] Dict fails to notice addition and deletion of keys during iteration

2009-05-16 Thread Georg Brandl
Georg Brandl added the comment: I wouldn't call it *wrong* as much as *not the whole truth*. It is true that if just one key is added or removed, a RuntimeError will be raised. There are probably lots of places in our docs where the whole truth isn't told, but in a way that works if you do the

[issue6017] Dict fails to notice addition and deletion of keys during iteration

2009-05-16 Thread Steven D'Aprano
Steven D'Aprano added the comment: With respect Georg, given that the behaviour won't be changed, the documentation is simply *wrong*. It's not a matter of telling people "don't do this" -- somebody, somewhere, is going to rely on the documented behaviour. The docs make the clear promise that

[issue6017] Dict fails to notice addition and deletion of keys during iteration

2009-05-16 Thread R. David Murray
R. David Murray added the comment: The precisionist in me insists that at a minimum 'will' should be changed to 'may'. Otherwise either the docs are lying or the implementation has a bug. Or perhaps we could add a footnote about the intentionally divergent behavior of the CPython implementatio

[issue6017] Dict fails to notice addition and deletion of keys during iteration

2009-05-16 Thread Georg Brandl
Georg Brandl added the comment: I don't think it would be better to change the documentation to "will raise a RuntimeError or result in undefined behavior." It already tells you not to do this strongly enough. -- status: open -> closed ___ Python tr

[issue6017] Dict fails to notice addition and deletion of keys during iteration

2009-05-16 Thread Steven D'Aprano
Steven D'Aprano added the comment: I agree with Terry Reedy. I'm re-opening it as a documentation bug (if I can -- if I can't, I'll just request somebody who can do so). -- components: -Interpreter Core status: closed -> open ___ Python tracker

[issue6017] Dict fails to notice addition and deletion of keys during iteration

2009-05-15 Thread Terry J. Reedy
Terry J. Reedy added the comment: The OP reported a real mismatch between doc and behavior. If the behavior is not changed, I think the doc should be. Other implementors, reading the doc, might think that they do have to write code to track changes. From the doc, I thought that CPython did th

[issue6017] Dict fails to notice addition and deletion of keys during iteration

2009-05-14 Thread Benjamin Peterson
Benjamin Peterson added the comment: This is correct; dict iterators check to see if the size of the dict is different. However, fixing this problem would require tracking dict contents during iteration. That strikes me as too inefficient and too much code for this little case. -- nosy:

[issue6017] Dict fails to notice addition and deletion of keys during iteration

2009-05-13 Thread Steven D'Aprano
New submission from Steven D'Aprano : I'm not sure if this is a documentation bug or a behaviour bug, or possibly both. The documentation warns about adding or deleting items from a dict while iterating over it: "Using iteritems() while adding or deleting entries in the dictionary will raise