[issue14205] Raise an error if a dict is modified during a lookup

STINNER Victor report at bugs.python.org
Tue Mar 6 17:54:11 CET 2012


STINNER Victor <victor.stinner at gmail.com> added the comment:

> Can't this be triggered by non-malicious code that just happened to have a python comparison and get hit with a thread switch?

The issue was triggered without threads.If the __eq__ method of the
objects used for keys use C functions releasing the GIL, you may
trigger the issue.

> Would it be worth adding a counter to lookdict, so that one modification is OK, but 5 aren't?

If you implement a special type modifying the dict that contains the
object, you should implement your own retry function on lookup failure
(catch RuntimeError).

Honestly, if you get RuntimeError, you should change your program, not
retry the lookup!

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14205>
_______________________________________


More information about the Python-bugs-list mailing list