Skip to content
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

gh-94808: add tests covering PyFunction_GetKwDefaults and PyFunction_SetKwDefaults #98809

Merged

Conversation

sobolevn
Copy link
Member

@sobolevn sobolevn commented Oct 28, 2022

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

@sobolevn sobolevn force-pushed the cover-pyfunction-get-set-kw-defaults branch from c85132f to a200c39 Compare October 28, 2022 12:31
@sobolevn sobolevn added tests Tests in the Lib/test dir skip news labels Oct 28, 2022
@iritkatriel iritkatriel self-assigned this Nov 5, 2022
@@ -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
Copy link
Member

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.

Copy link
Member

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 iritkatriel added needs backport to 3.10 only security fixes needs backport to 3.11 only security fixes labels Nov 5, 2022
@iritkatriel iritkatriel changed the title gh-94808: Cover PyFunction_GetKwDefaults and PyFunction_SetKwDefaults gh-94808: add tests covering PyFunction_GetKwDefaults and PyFunction_SetKwDefaults Nov 5, 2022
@iritkatriel iritkatriel removed the needs backport to 3.10 only security fixes label Nov 5, 2022
@iritkatriel iritkatriel merged commit 317acb8 into python:main Nov 5, 2022
@miss-islington
Copy link
Contributor

Thanks @sobolevn for the PR, and @iritkatriel for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs backport to 3.11 only security fixes skip news tests Tests in the Lib/test dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants