[New-bugs-announce] [issue25315] OrderedDict mangled private attribute is inaccessible
Serge Matveenko (lig)
report at bugs.python.org
Mon Oct 5 04:03:07 CEST 2015
New submission from Serge Matveenko (lig):
Consider this code in Python 3.5.0:
Python 3.5.0 (default, Sep 26 2015, 14:59:25)
[GCC 5.1.1 20150618 (Red Hat 5.1.1-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from collections import OrderedDict
>>> class MyDict(OrderedDict):
... def __setitem__(self, *args, **kwargs):
... print(self._OrderedDict__root)
... OrderedDict.__setitem__(self, *args, **kwargs)
...
>>> md = MyDict({'a': 1})
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 3, in __setitem__
AttributeError: 'MyDict' object has no attribute '_OrderedDict__root'
However in Python 3.4:
Python 3.4.2 (default, Jul 9 2015, 17:24:30)
[GCC 5.1.1 20150618 (Red Hat 5.1.1-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from collections import OrderedDict
>>> class MyDict(OrderedDict):
... def __setitem__(self, *args, **kwargs):
... print(self._OrderedDict__root)
... OrderedDict.__setitem__(self, *args, **kwargs)
...
>>> md = MyDict({'a': 1})
<collections._Link object at 0x7f0398a79b88>
----------
components: Library (Lib)
messages: 252296
nosy: Serge Matveenko (lig)
priority: normal
severity: normal
status: open
title: OrderedDict mangled private attribute is inaccessible
type: behavior
versions: Python 3.5
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25315>
_______________________________________
More information about the New-bugs-announce
mailing list