Skip to content

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

Merged
iritkatriel merged 3 commits into
python:mainfrom
sobolevn:cover-pyfunction-get-set-kw-defaults
Nov 5, 2022
Merged

gh-94808: add tests covering PyFunction_GetKwDefaults and PyFunction_SetKwDefaults#98809
iritkatriel merged 3 commits into
python:mainfrom
sobolevn:cover-pyfunction-get-set-kw-defaults

Conversation

@sobolevn

@sobolevnsobolevn commented Oct 28, 2022

Copy link
Copy Markdown
Member

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
sobolevnforce-pushed the cover-pyfunction-get-set-kw-defaults branch from c85132f to a200c39CompareOctober 28, 2022 12:31
@sobolevnsobolevn added tests Tests in the Lib/test dir skip news labels Oct 28, 2022
@iritkatrieliritkatriel self-assigned this Nov 5, 2022
Comment threadLib/test/test_capi.py
@@ -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
Copy Markdown
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
Copy Markdown
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.

@iritkatrieliritkatriel added needs backport to 3.10 only security fixes needs backport to 3.11 only security fixes labels Nov 5, 2022
@iritkatrieliritkatriel changed the title gh-94808: Cover PyFunction_GetKwDefaults and PyFunction_SetKwDefaultsgh-94808: add tests covering PyFunction_GetKwDefaults and PyFunction_SetKwDefaultsNov 5, 2022
@iritkatrieliritkatriel removed the needs backport to 3.10 only security fixes label Nov 5, 2022
@iritkatriel
iritkatriel merged commit 317acb8 into python:mainNov 5, 2022
@miss-islington

Copy link
Copy Markdown
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
Copy Markdown
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

@ZeroIntensityZeroIntensity removed the needs backport to 3.11 only security fixes label Feb 17, 2025
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip newstestsTests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@sobolevn@miss-islington@iritkatriel@bedevere-bot@ZeroIntensity