[Python-Dev] FYI dict lookup now raises a RuntimeError if the dict is modified during the lookup
Victor Stinner
victor.stinner at gmail.com
Fri Mar 9 13:48:35 CET 2012
If you use your own comparaison function (__eq__) for objects used as
dict keys, you may now get RuntimeError with Python 3.3 if the dict is
modified during a dict lookup in a multithreaded application. You
should use a lock on the dict to avoid this exception.
Said differently, a dict lookup is not atomic if you use your own
types as dict keys and these types implement __eq__.
In Python < 3.3, the dict lookup is retried until the dict is no more
modified during the lookup, which leads to a stack overflow crash if
the dict is always modified.
See the issue #14205 for the rationale.
Victor
More information about the Python-Dev
mailing list