[issue25315] OrderedDict mangled private attribute is inaccessible

2015-10-07 Thread Serge Matveenko

Serge Matveenko added the comment:

Sorry for reopening. I completely agree with the point that is it not necessary 
for Python and C implementations to duplicate each other.

But then the Python OrderedDict implementation should be dropped from the 
library source. The code that is there now is nothing more than confusing. For 
some one not aware of C implementation it is very hard to get from 
documentation that the code she sees via "Go to definition" feature of her IDE 
is not meant to be executing at all.

--
resolution: not a bug -> 
status: closed -> open

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25315] OrderedDict mangled private attribute is inaccessible

2015-10-07 Thread Emanuel Barry

Emanuel Barry added the comment:

The Python implementation will stay for two main reasons, one to provide a 
working implementation for all those who wish to use a modified version (you, 
for example, if you want to use a version that lets you alter order), and two 
for alternate implementations which don't have OrderedDict in the _collections 
module (a comment even hints at that in the source).

I fully agree on the confusing part, however. Maybe a comment could be added 
regarding this.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25315] OrderedDict mangled private attribute is inaccessible

2015-10-05 Thread R. David Murray

R. David Murray added the comment:

Yes, that would be correct.  OrderedDict is designed to keep things in 
insertion order, so supporting changing that order is not part of its mission.  
Sorry about that, you'll have to write your own class.

Now, Raymond might find the idea of supporting other orders interesting.  If so 
I'm sure he'll comment on the issue eventually.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25315] OrderedDict mangled private attribute is inaccessible

2015-10-05 Thread Serge Matveenko

Serge Matveenko added the comment:

Ok, then the OrderedDict is useless for any advanced hacking like altering the 
order in which __setitem__ stores items.

It is just useless Python code and so much appliances missed for this class:(

Thank you all for these completely helpful answers.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25315] OrderedDict mangled private attribute is inaccessible

2015-10-05 Thread Serge Matveenko

Serge Matveenko added the comment:

Zach, ok I got your point. But there is Python implementation in the library 
still which does not conform the one done in C. Such a behavior is tremendously 
confusing.

If there is both Python and C implementation in the library they must conform 
each other. And there is nothing with "you *really* shouldn't use this" when 
you need to especially when it is there. If it is there it must work as it 
written. Otherwise why Python does have this peace of code while it is 
completely useless as reference?

--
resolution: wont fix -> 
status: closed -> open

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25315] OrderedDict mangled private attribute is inaccessible

2015-10-05 Thread Serge Matveenko

Serge Matveenko added the comment:

If Python source does conform the one in C, it will be completely fine and 
understandable to have such a change and to rely on it in using version checks 
or whatever.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25315] OrderedDict mangled private attribute is inaccessible

2015-10-05 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
assignee:  -> rhettinger
nosy: +rhettinger
priority: normal -> low

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25315] OrderedDict mangled private attribute is inaccessible

2015-10-05 Thread Emanuel Barry

Emanuel Barry added the comment:

The same is true of the decimal and datetime modules. Names starting with an 
underscore are an implementation detail, and you shouldn't rely on these in 
production code.

--
nosy: +ebarry

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25315] OrderedDict mangled private attribute is inaccessible

2015-10-05 Thread R. David Murray

R. David Murray added the comment:

A method that starts with an '_' is not part of the API unless documented to be 
so (as with namedtuple), and a non-special method that starts with two is 
purposefully mangled so that you cannot accidentally rely on it.  The C 
implementation is an implementation of the API and the behavior when that API 
is used (as vetted by the tests that are run against both implementations); it 
is not otherwise required to "conform" to the python implementation or vice 
versa.

--
nosy: +r.david.murray
resolution:  -> not a bug
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25315] OrderedDict mangled private attribute is inaccessible

2015-10-04 Thread Serge Matveenko (lig)

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 "", line 1, in 
  File "", 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})


--
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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25315] OrderedDict mangled private attribute is inaccessible

2015-10-04 Thread Zachary Ware

Zachary Ware added the comment:

This is a side-effect of 3.5 having a C implementation of OrderedDict, and will 
not be fixed.

In the standard library, even just having a single trailing underscore is a 
clear indication of "if you use this, expect it to break without warning at any 
time."  Mangled names in the standard library are more of an indication of "you 
*really* shouldn't use this".

--
nosy: +eric.snow, zach.ware
resolution:  -> wont fix
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com