gh-94808: add tests covering `PyFunction_GetKwDefaults` and `PyFunction_SetKwDefaults` by sobolevn · Pull Request #98809 · python/cpython
There are also several changes to PyFunction_[G|S]etDefaults tests:
- I've added all types of arguments to function: including pos-only args
- I've fixed one copy-paste error
- I've added more corner cases to the test
Refs: #98449
| @@ -963,6 +977,8 @@ def some(pos_only='p', zero=0, optional=None): | |||
|
|
|||
| with self.assertRaises(SystemError): | |||
| _testcapi.function_set_defaults(some, 1) # not tuple or None | |||
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to check here that a failed set in fact did not change the defaults.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see this is checked after the next failed set. But better to check every time.
iritkatriel
changed the title
gh-94808: Cover
gh-94808: add tests covering PyFunction_GetKwDefaults and PyFunction_SetKwDefaultsPyFunction_GetKwDefaults and PyFunction_SetKwDefaults
Thanks @sobolevn for the PR, and @iritkatriel for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11.
🐍🍒⛏🤖
Sorry, @sobolevn and @iritkatriel, I could not cleanly backport this to 3.11 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 317acb80387674db8c94f48bb9823ae516d05f5c 3.11