On Tue, 29 Nov 2016 at 10:28 Nick Timkovich <prometheus235@gmail.com> wrote:
I would consider the speed of the "ultimate error handler" (i.e. whatever prints the traceback and kills the program) in the interpreter to be moot, so long as it takes a small fraction of a second. Optimizing Python's speed it crashes super-fast due to an *unhandled* NameError in your program seems folly.

So the performance worry isn't the traceback printer once the call stack fully unwinds but the construction of the exception instance itself. E.g. having to construct an expensive string for every instance of AttributeError is more the worry than printing a traceback.
 

Regarding more informative messages for (e.g.) IndexError, would those just apply to built-in types as they're the most universal, or should some additional introspection be done for similar ducks? 

If it's useful/there's interest, I could try to do some analysis of Python questions on SO and see what the most common errors are. I'd guess things like "'NoneType' object has no attribute ..." would probably be up there, but that's a whole can of worms as to why someone's trying to call a method on, index, etc. something they accidentally whacked (a = a.sort()).

I suspect if we decide to try and go with more informative messages with a solution people are happy with then having an idea of where people get tripped up regularly will be good to help focus the work.

And as for the NoneType issue specifically, there's an issue for that: http://bugs.python.org/issue28702 .
 

On Tue, Nov 29, 2016 at 11:42 AM, Chris Barker <chris.barker@noaa.gov> wrote:
On Tue, Nov 29, 2016 at 5:48 AM, Nick Coghlan <ncoghlan@gmail.com> wrote:
> SyntaxErrors in an inner loop? That seems unlikely to me.

Syntax Errors are a special case, as by definition the code isn't being run yet (yes, there could be an eval in there...)

So we could at least make those more informative without worrying about performance.

Also -- would it be possible to tack on the more informative message at a higher level? Once the Exception bubbles up to the REPL, is there enough information available to make a more informative message?

-CHB
 

--

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker@noaa.gov

_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/