◐ Shell
clean mode source ↗

gh-107944: Improve error message for getargs with bad keyword arguments by hauntsaninja · Pull Request #114792 · python/cpython

hauntsaninja

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

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

I still need to do the vgetargskeywords path...

pablogsal

with self.check_suggestion_includes(suggestion):
func(bluch=None)

def test_unexpected_keyword_suggestion_via_getargs(self):

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

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.

pablogsal

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

fsc-eriker pushed a commit to fsc-eriker/cpython that referenced this pull request

Feb 14, 2024