Author ShaneHarvey
Recipients ShaneHarvey
Date 2017-08-02.18:53:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1501699994.79.0.0201468057837.issue31107@psf.upfronthosting.co.za>
In-reply-to
Content
This line in copyreg._slotnames does not properly calculate mangled attribute names:
https://github.com/python/cpython/blob/v3.6.2/Lib/copyreg.py#L131

The problem is that it does not strip leading underscores from the class name:

>>> class _LeadingUnderscoreClassName(object):
...     __slots__ = ("__bar",)
...
>>> import copy_reg
>>> copy_reg._slotnames(_LeadingUnderscoreClassName)
['__LeadingUnderscoreClassName__bar']

The result is that copy, pickle, and anything else that relies on _slotnames() do not work on classes with leading underscores and private __slots__. This bug is present in all versions of Python.
History
Date User Action Args
2017-08-02 18:53:14ShaneHarveysetrecipients: + ShaneHarvey
2017-08-02 18:53:14ShaneHarveysetmessageid: <1501699994.79.0.0201468057837.issue31107@psf.upfronthosting.co.za>
2017-08-02 18:53:14ShaneHarveylinkissue31107 messages
2017-08-02 18:53:14ShaneHarveycreate