New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When a TypeError is raised due to invalid arguments to a method, it should use __qualname__ to identify the class the method is in #71576
Comments
When a method is called with incorrect arguments (too many or too few, for instance), a TypeError is raised. The message in the TypeError generally of the form:
I think the message should include the class name along with the method name, so it would say Here's an example showing how the current error messages can be ambiguous: class A:
def foo(self, x):
pass
class B:
def foo(self, x, y): # different method signature!
pass
lst = [A(), B()]
for item in lst:
item.foo(1) # raises TypeError: foo() missing 1 required positional argument: 'y'"
for item in lst:
item.foo(1, 2) # raises "TypeError: foo() takes 2 positional arguments but 3 were given" In neither loop is is clear which class's I've looked through the code and the two exceptions above come from the Several other argument related TypeError exceptions are raised directly in _PyEval_EvalCodeWithName, which does have a A few extra TypeErrors related to function calls are raised directly in the gigantic |
Have a look at bpo-2786. I think it might be the same thing. |
Yes, this looks to be a duplicate of that issue. I'm closing this issue as a duplicate, but I don't seem to be able to set the Superseder field. If you can, please set that to bpo-2786. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: