[issue39625] Traceback needs more details

Ammar Askar report at bugs.python.org
Sun Feb 16 03:31:53 EST 2020


Ammar Askar <ammar at ammaraskar.com> added the comment:

I don't know how common this situation is, the fact that all constructors go to __init__ here makes it a little tough in this case but normally you'd be able to tell by the function name.

One potential solution might be to show which file the error came from like this:

Traceback (most recent call last):
  File "D:\x.py", line 13, in <module>
    c = C(C1("C1"), C2("C2"))
TypeError: [D:\x.py:6] __init__() missing 1 required positional argument: 'p'

This is a pretty trivial change in ceval.c:3779 but might make the errors pretty long unless (especially now that co_filename is an absolute path) we chop them off to just the name of the file.

Including the frame information for the function about to be called would be much more difficult.

Overall this situation might not be worth improving because it's so rare but having the function location in the error might be worth having just as an extra information point.

----------
nosy: +ammar2

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39625>
_______________________________________


More information about the Python-bugs-list mailing list