Hah, should have put more effort in my research then. And so recent too.
Well, it is not something easy to search for.
I read the other thread, and I am inclined to agree with Paul. Whether
or not the execution enters the function (as in: new entry in the call
stack) during setup is really an implementation detail.
For the very same reason, I also see why the CPython devs don't want to
include a fake extra stack layer.
Still, personally, I think that during the checking of the function
arguments, execution is logically closer to the function than the point
where it was called. I also think that the stack part of the traceback
*is* the right place to display this information.
I'd also be fine with an extended exception message though.
In the end, I think this is a trivial improvement. (Trivial as in 'no
adverse side effects', not trivial to implement).
Regardless if it has affected many users in the past or not (I'd say it
did!).
I am anything but an authoritative figure on the matter, so just
consider this a firm +1 from another user.
Cheers
Pol
On 2021-04-21 01:20, Paul Sokolovsky wrote:
Hello,
On Tue, 20 Apr 2021 18:23:15 -0000
"Pol Welter" <polwel...@gmail.com> wrote:
Consider the following snippet:
```
def foo(a, b):
pass
foo(1, 2, 3)
```
We all know what will happen.
```
File "<stdin>", line 4, in <module>
foo(1, 2, 3)
TypeError: foo() takes 2 positional arguments but 3 were given
```
Would it be reasonable to include the line number for the function
`foo()` that it resolved the call to? I.e. 'File "<stdin>", line 1,
in foo'.
There are situations (e.g. monkey patch) where this is not obvious.
Would be great detail to include that in the traceback, I think.
That was reported some time ago:
https://groups.google.com/g/dev-python/c/xdcpSJN17QQ
https://groups.google.com/g/python-ideas/c/3jEZ9F-oUr0
Just as you, I had hard time to believe that wasn't fixed over 30 years
of CPython history.
I fixed that in my Python dialect, https://github.com/pfalcon/pycopy ,
and enjoyed it thoroughly on multiple occasions since then. For the
snippet above (put in a file):
Traceback (most recent call last):
File "ex.py", line 4, in <module>
File "ex.py", line 2, in foo
TypeError: foo() takes 2 positional arguments but 3 were given
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/python-ideas@python.org/message/OUY5VKVRN5UYIK63EH4DV2JKYJGVS3GR/
Code of Conduct: http://python.org/psf/codeofconduct/