Message222099
`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:12 | Olivier.Grisel | set | recipients:
+ Olivier.Grisel |
2014-07-02 13:03:12 | Olivier.Grisel | set | messageid: <1404306192.8.0.184744206475.issue21905@psf.upfronthosting.co.za> |
2014-07-02 13:03:12 | Olivier.Grisel | link | issue21905 messages |
2014-07-02 13:03:12 | Olivier.Grisel | create | |
|