[New-bugs-announce] [issue31107] copyreg does not properly mangle __slots__ names
Shane Harvey
report at bugs.python.org
Wed Aug 2 14:53:14 EDT 2017
New submission from Shane Harvey:
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.
----------
components: Library (Lib)
messages: 299665
nosy: Shane Harvey
priority: normal
severity: normal
status: open
title: copyreg does not properly mangle __slots__ names
type: behavior
versions: Python 2.7, Python 3.3, Python 3.4, Python 3.5, Python 3.6, Python 3.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue31107>
_______________________________________
More information about the New-bugs-announce
mailing list