[issue28869] __module__ attribute is not set correctly for a class created by direct metaclass call
Serhiy Storchaka
report at bugs.python.org
Sun Jun 16 15:37:09 EDT 2019
Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:
>>> from abc import *
>>> A = ABCMeta('A', (), {})
>>> A.__module__
'abc'
>>> import pickle, pickletools
>>> pickletools.dis(pickletools.optimize(pickle.dumps(A)))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
_pickle.PicklingError: Can't pickle <class 'abc.A'>: attribute lookup A on abc failed
>>> A.__module__ = None
>>> pickletools.dis(pickletools.optimize(pickle.dumps(A)))
0: \x80 PROTO 4
2: \x95 FRAME 15
11: \x8c SHORT_BINUNICODE '__main__'
21: \x8c SHORT_BINUNICODE 'A'
24: \x93 STACK_GLOBAL
25: . STOP
highest protocol among opcodes = 4
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue28869>
_______________________________________
More information about the Python-bugs-list
mailing list