[Python-Dev] Re: Reviving PEP 473

2021-03-16 Thread Victor Stinner
For best performance (reduce time to build an exception object), I would be interested to only format the error message on demand. For example, when str(exception) is called. The problem is the Exception.args attribute. Example: $ ./python Python 3.10.0a6+ >>> exc=AttributeError("%s object has no

[Python-Dev] Re: Reviving PEP 473

2021-03-15 Thread André Roberge
I am not a Python developer, but I am very interested in this topic. While I would definitely make use of any additional fields for exceptions as discussed, it is already possible to find most, if not all of the information discussed in PEP 473. To give just a concrete example taken from the PE

[Python-Dev] Re: Reviving PEP 473

2021-03-15 Thread Brett Cannon
Since tweaking the built-in exceptions is so far-reaching, probably at least discussing each proposed change (one at a time, not 5 at once) would be the minimum. Otherwise you could do a PEP, but once again you're looking at a PEP per exception. I think it's really going to come down to how big of

[Python-Dev] Re: Reviving PEP 473

2021-03-13 Thread Victor Stinner
Context: PEP 473 "Adding structured data to built-in exceptions" proposed in 2014. https://www.python.org/dev/peps/pep-0473/ Abstract: "Exceptions like AttributeError, IndexError, KeyError, LookupError, NameError, TypeError, and ValueError do not provide all information required by programmers to