[issue27541] Repr of collection's subclasses

2017-09-21 Thread STINNER Victor
STINNER Victor added the comment: > Because reprs of Python implementations of collection use a bare __name__. Ah, maybe this module should be updated to use qualified name with the name in repr()? > __qualname__ is used only in combination with __module__. I was thinking at module.qualname,

[issue27541] Repr of collection's subclasses

2017-09-21 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Because reprs of Python implementations of collection use a bare __name__. __qualname__ is used only in combination with __module__. Using a single __qualname__ can be confused: foo.bar looks as a name bar in the module foo. Whether in reprs and error messag

[issue27541] Repr of collection's subclasses

2017-09-21 Thread STINNER Victor
STINNER Victor added the comment: Why using type.__name__ rather than type.__qualname__? -- nosy: +haypo ___ Python tracker ___ ___ P

[issue27541] Repr of collection's subclasses

2017-09-21 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Thanks Raymond. -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___ __

[issue27541] Repr of collection's subclasses

2017-09-21 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: New changeset b3a77964ea89a488fc0e920e3db6d8477279f19b by Serhiy Storchaka in branch 'master': bpo-27541: Reprs of subclasses of some classes now contain actual type name. (#3631) https://github.com/python/cpython/commit/b3a77964ea89a488fc0e920e3db6d8477279f

[issue27541] Repr of collection's subclasses

2017-09-17 Thread Raymond Hettinger
Changes by Raymond Hettinger : -- Removed message: https://bugs.python.org/msg302377 ___ Python tracker ___ ___ Python-bugs-list mail

[issue27541] Repr of collection's subclasses

2017-09-17 Thread Raymond Hettinger
Raymond Hettinger added the comment: +1 for changing the cases Serhiy found. Also, I agree with Serhiy that there should not be a change for the built-in types that have a literal notation (it has been this was forever, hasn't caused any real issues, and changing it now will likely break cod

[issue27541] Repr of collection's subclasses

2017-09-17 Thread Raymond Hettinger
Raymond Hettinger added the comment: +1 for changing the cases Serhiy found. Also, I agree with Serhiy that there should be a change for the built-in types that have a literal notation (it has been this was forever, hasn't caused any real issues, and changing it now will likely break code).

[issue27541] Repr of collection's subclasses

2017-09-17 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- dependencies: +Add _PyType_Name() versions: +Python 3.7 -Python 3.6 ___ Python tracker ___ ___ Pytho

[issue27541] Repr of collection's subclasses

2017-09-17 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- keywords: +patch pull_requests: +3620 stage: -> patch review ___ Python tracker ___ ___ Python-bugs

[issue27541] Repr of collection's subclasses

2016-07-17 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: It looks to me that the repr of a collection contains a dynamic name if it is implemented in Python and hardcoded base name if it is implemented in C (OrderedDict originally was implemented in Python). Maybe just because tp_name contains full qualified name,

[issue27541] Repr of collection's subclasses

2016-07-17 Thread R. David Murray
R. David Murray added the comment: It certainly seems that collections should be consistent about this. The question of builtin types is a different issue, and I agree that it is probably way more trouble than it is worth to change them, especially since, for example, repr(str) is often used

[issue27541] Repr of collection's subclasses

2016-07-17 Thread Raymond Hettinger
Changes by Raymond Hettinger : -- assignee: -> rhettinger ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http

[issue27541] Repr of collection's subclasses

2016-07-17 Thread Xiang Zhang
Xiang Zhang added the comment: Yes. So if we are not going to change other built-in types, maybe we'd better not change bytearray either. My opinion is that don't change built-in classes, even bytearray. If users would like a more reasonable repr, they can provide a custom __repr__ as your exa

[issue27541] Repr of collection's subclasses

2016-07-17 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: This can break third-party code. For example the code that explicitly makes the repr containing a subclass name: class MyStr(str): def __repr__(self): return 'MyStr(%s)' % str.__repr__(self) I think the chance of breaking third-party code for byt

[issue27541] Repr of collection's subclasses

2016-07-17 Thread Xiang Zhang
Xiang Zhang added the comment: How about other built-in classes? If repr does matter, maybe str, int, dict should also respect this rule? -- ___ Python tracker ___ _

[issue27541] Repr of collection's subclasses

2016-07-17 Thread Serhiy Storchaka
New submission from Serhiy Storchaka: The repr of subclasses of some collection classes contains a name of the subclass: >>> class S(set): pass ... >>> S([1, 2, 3]) S({1, 2, 3}) >>> import collections >>> class OD(collections.OrderedDict): pass ... >>> OD({1: 2}) OD([(1, 2)]) >>> class C(coll