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, and extracting a bare class name needs few lines 
of code.

There is similar issue with the io module classes: issue21861.

Since this problem is already solved for OrderedDict, I think it is easy to use 
this solution in other classes. Maybe factoring out the following code into 
helper function.

    const char *classname;

    classname = strrchr(Py_TYPE(self)->tp_name, '.');
    if (classname == NULL)
        classname = Py_TYPE(self)->tp_name;
    else
        classname++;

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue27541>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to