Nick Coghlan added the comment:

That said, bringing over my overall comment from the PR review: 

I think the number of additional changes needed in the test suite and the 
standard library highlights the compatibility restoration busy-work risks of 
actually making this change:

- while test_structures and test_xmlrpc show the kinds of error messages that 
the change is aimed at improving (and I think it does indeed improve them), it 
still requires the kind of test case change that is going to be awkward from 
projects spanning multiple distinct versions of CPython

- most of the other cases were for code that actually wanted the current 
formatting, and needed to be updated to explicitly request repr() (either by 
calling it directly, or by switching to !r or %r in a formatting string)

Perhaps a less disruptive way of tackling the problem with the verbosity of 
name access would be to add a new `getname()` builtin that understood how to 
get the names of various things (e.g. via `__class__`), and preferred 
__qualname__ to __name__ when both were available? Then Guido's original 
motivating example could be written as:

    print(f"{getname(err)}: {err}") # f-string
    print("{}: {}".format(getname(err), err) # str.format
    print("%s: %s" % (getname(err), err)) # printf-style

As a new builtin, it could be trivially added to cross-version compatibility 
libraries like six and python-future, whereas directly changing the behaviour 
of __str__ on the affected builtin types isn't really something that can be 
readily emulated on old versions.

----------

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

Reply via email to