GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-94808: cover `PyFunction_GetDefaults` and `PyFunction_SetDefaults` by sobolevn · Pull Request #98449 · python/cpython

Conversation

@sobolevn

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

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member
  • Issue: Metabug: Improving C-level coverage #94808

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@sobolevn
pythongh-94808: cover PyFunction_GetDefaults and `PyFunction_SetDef…
25a6fbb
…aults`
@bedevere-bot bedevere-bot added the awaiting review label Oct 19, 2022
@sobolevn sobolevn added the skip news label Oct 19, 2022
@mdboom mdboom mentioned this pull request Oct 19, 2022
Metabug: Improving C-level coverage #94808
Open
@sobolevn

sobolevn commented Oct 20, 2022

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;
}
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

JelleZijlstra
JelleZijlstra approved these changes Oct 21, 2022
View reviewed changes
Comment thread Modules/_testcapimodule.c
{
PyObject *defaults = PyFunction_GetDefaults(func);
if (defaults != NULL) {
Py_INCREF(defaults);

@JelleZijlstra JelleZijlstra Oct 21, 2022

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is correct because PyFunction_GetDefaults returns a borrowed ref.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting review labels Oct 21, 2022
@JelleZijlstra
Merge branch 'main' into cover-pyfunction-get-set-defaults
b3c88e6
@JelleZijlstra JelleZijlstra self-assigned this Oct 26, 2022
@JelleZijlstra
JelleZijlstra merged commit 7b24333 into python:main Oct 27, 2022
@bedevere-bot bedevere-bot removed the awaiting merge label Oct 27, 2022
@JelleZijlstra JelleZijlstra added needs backport to 3.10 needs backport to 3.11 only security fixes labels Oct 27, 2022
@miss-islington

miss-islington commented 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!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington

miss-islington commented 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.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington

miss-islington commented Oct 27, 2022

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington

miss-islington commented Oct 27, 2022

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

miss-islington commented 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!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington

miss-islington commented Oct 27, 2022

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@JelleZijlstra

JelleZijlstra commented Oct 27, 2022

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?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sobolevn sobolevn mentioned this pull request Oct 28, 2022
gh-94808: add tests covering PyFunction_GetKwDefaults and PyFunction_SetKwDefaults #98809
Merged
gvanrossum pushed a commit to gvanrossum/cpython that referenced this pull request Oct 28, 2022
@sobolevn @gvanrossum
pythongh-94808: cover PyFunction_GetDefaults and `PyFunction_SetDef…
5820f05
…aults` (python#98449)
@ZeroIntensity ZeroIntensity removed the needs backport to 3.11 only security fixes label Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@JelleZijlstra JelleZijlstra JelleZijlstra approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@JelleZijlstra JelleZijlstra

Labels

skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@sobolevn @miss-islington @JelleZijlstra @bedevere-bot @ZeroIntensity
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.