Richard Oudkerk added the comment:

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

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue17941>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to