This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Olivier.Grisel
Recipients Olivier.Grisel
Date 2014-07-02.13:03:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
`pickle.whichmodule` performs an iteration over `sys.modules` and tries to perform `getattr` calls on those modules. Unfortunately some modules such as those from the `six.moves` dynamic module can trigger imports when calling `getattr` on them, hence mutating the `sys.modules` dict and causing a `RuntimeError: dictionary changed size during iteration`.

This would also render `pickle.whichmodule` more thread-safe and cause concurrent thread perform new module imports and `whichmodule` calls.

The attach patch protect the iterator by copying the dict items into a fixed list.

I could write a tests involving dynamic module definitions as done in `six.moves` but it sounds very complicated for such a trivial fix.
Date User Action Args
2014-07-02 13:03:12Olivier.Griselsetrecipients: + Olivier.Grisel
2014-07-02 13:03:12Olivier.Griselsetmessageid: <>
2014-07-02 13:03:12Olivier.Grisellinkissue21905 messages
2014-07-02 13:03:12Olivier.Griselcreate