Thanks to visit codestin.com
Credit goes to github.com

Skip to content

gh-107944: Improve error message for getargs with bad keyword arguments #114792

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

Merged
merged 6 commits into from
Feb 8, 2024

Conversation

hauntsaninja
Copy link
Contributor

@hauntsaninja hauntsaninja commented Jan 31, 2024

}
else {
PyErr_Format(PyExc_TypeError,
"%.200s%s got an unexpected keyword argument '%S'",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made this error message match the one in ceval.c

@hauntsaninja
Copy link
Contributor Author

I still need to do the vgetargskeywords path...

@@ -987,6 +987,14 @@ def case_change_over_substitution(BLuch=None, Luch = None, fluch = None):
with self.check_suggestion_includes(suggestion):
func(bluch=None)

def test_unexpected_keyword_suggestion_via_getargs(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mind adding a explicit test for when the suggestion fails (the 'else' case in the conditional here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review! I added this test.

I also made a similar edit in the vgetargskeywords code path and added tests.

Copy link
Member

@pablogsal pablogsal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good work @hauntsaninja! Thanks for working on this

This looks great, I left some nit but please feel free to ignore

@hauntsaninja hauntsaninja merged commit 17689e3 into python:main Feb 8, 2024
@hauntsaninja hauntsaninja deleted the gh107944 branch February 8, 2024 09:04
fsc-eriker pushed a commit to fsc-eriker/cpython that referenced this pull request Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants