Message189168
| Author |
sbt |
| Recipients |
barry, eli.bendersky, eric.smith, gvanrossum, ncoghlan, rhettinger, sbt |
| Date |
2013年05月13日.19:41:31 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<519141E7.4020100@gmail.com> |
| In-reply-to |
<1368471793.97.0.603295844297.issue17941@psf.upfronthosting.co.za> |
| Content |
When pickling a class (or instance of a class) there is already a check
that the invariant
getattr(sys.modules[cls.__module__], cls.__name__) == cls
holds.
>>> import pickle
>>> class A: pass
...
>>> A.__module__ = 'nonexistent'
>>> pickle.dumps(A())
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
_pickle.PicklingError: Can't pickle <class 'nonexistent.A'>: import of
module 'nonexistent' failed |
|