← 返回首页
gh-94808: cover `PyFunction_GetDefaults` and `PyFunction_SetDefaults` by sobolevn · Pull Request #98449 · python/cpython · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

gh-94808: cover PyFunction_GetDefaults and PyFunction_SetDefaults#98449

Merged
JelleZijlstra merged 2 commits into
python:mainfrom
sobolevn:cover-pyfunction-get-set-defaults
Oct 27, 2022
Merged

gh-94808: cover PyFunction_GetDefaults and PyFunction_SetDefaults#98449
JelleZijlstra merged 2 commits into
python:mainfrom
sobolevn:cover-pyfunction-get-set-defaults

Conversation

sobolevn commented Oct 19, 2022
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Member

Copy link
Copy Markdown
Member Author

There's a difference with func_get_defaults:

static PyObject * func_get_defaults(PyFunctionObject *op, void *Py_UNUSED(ignored)) { if (PySys_Audit("object.__getattr__", "Os", op, "__defaults__") < 0) { return NULL; } if (op->func_defaults == NULL) { Py_RETURN_NONE; } Py_INCREF(op->func_defaults); return op->func_defaults; }

Comment thread Modules/_testcapimodule.c
{
PyObject *defaults = PyFunction_GetDefaults(func);
if (defaults != NULL) {
Py_INCREF(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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

This is correct because PyFunction_GetDefaults returns a borrowed ref.

JelleZijlstra self-assigned this Oct 26, 2022
JelleZijlstra merged commit 7b24333 into python:main Oct 27, 2022
JelleZijlstra added needs backport to 3.10 only security fixes needs backport to 3.11 only security fixes labels Oct 27, 2022

Copy link
Copy Markdown
Contributor

Thanks @sobolevn for the PR, and @JelleZijlstra for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

Sorry, @sobolevn and @JelleZijlstra, I could not cleanly backport this to 3.10 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 7b24333fff51f9ca36ef19748016cc2b39ab6301 3.10

Copy link
Copy Markdown
Contributor

Sorry @sobolevn and @JelleZijlstra, I had trouble checking out the 3.11 backport branch.
Please retry by removing and re-adding the "needs backport to 3.11" label.
Alternatively, you can backport using cherry_picker on the command line.
cherry_picker 7b24333fff51f9ca36ef19748016cc2b39ab6301 3.11

JelleZijlstra added needs backport to 3.11 only security fixes and removed needs backport to 3.10 only security fixes needs backport to 3.11 only security fixes labels Oct 27, 2022

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

Sorry, @sobolevn and @JelleZijlstra, I could not cleanly backport this to 3.11 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 7b24333fff51f9ca36ef19748016cc2b39ab6301 3.11

Copy link
Copy Markdown
Member

@sobolevn (and maybe @mdboom) do you think it's worth manually backporting this, or are we only aiming for full coverage on main?

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

Footer

© 2026 GitHub, Inc.