Skip to content

gh-101072: support default and kw default in PyEval_EvalCodeEx for 3.11+ #101127

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

Merged

Conversation

MatthieuDartiailh
Copy link
Contributor

@MatthieuDartiailh MatthieuDartiailh commented Jan 18, 2023

Fixes the regression observed in PyEval_EvalCodeEx on 3.11+ and add a test to avoid future regressions.

This should be backported to 3.11 I believe.

@MatthieuDartiailh MatthieuDartiailh force-pushed the pyeval_evalcodeex_default_support branch from 9c50259 to 0bb1c96 Compare January 18, 2023 13:35
Copy link
Contributor

@kumaraditya303 kumaraditya303 left a comment

Choose a reason for hiding this comment

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

Please format the C code as per https://peps.python.org/pep-0007/

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@MatthieuDartiailh
Copy link
Contributor Author

I have made the requested changes; please review again

@bedevere-bot
Copy link

Thanks for making the requested changes!

@kumaraditya303: please review the changes made to this pull request.

Copy link
Contributor

@ambv ambv left a comment

Choose a reason for hiding this comment

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

👍🏻 Fix works.
👍🏻 New tests fail without the fix applied.
👎🏻 There's a refleak in the new test.

Before (main at 7a25310):

0:00:00 load avg: 3.77 [1/1] test_capi
beginning 9 repetitions
123456789
.........
test_capi passed in 49.2 sec

== Tests result: SUCCESS ==

After (this PR rebased on top of 7a25310):

0:00:00 load avg: 3.72 [1/1] test_capi
beginning 9 repetitions
123456789
.........
test_capi leaked [1, 1, 1, 1] references, sum=4
test_capi failed (reference leak) in 49.6 sec

== Tests result: FAILURE ==

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@ambv ambv requested a review from markshannon as a code owner February 6, 2023 20:24
Comment on lines -1764 to -1766
for (int i = 0; i < kwcount; i++) {
PyTuple_SET_ITEM(kwnames, i, Py_NewRef(kws[2*i]));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This code is duplicated in the block right above, leading to double new refs.

@MatthieuDartiailh
Copy link
Contributor Author

Thanks for the edits @ambv !

@ambv ambv dismissed kumaraditya303’s stale review February 7, 2023 08:48

I applied the formatting Kumar wanted

@ambv ambv merged commit ae62bdd into python:main Feb 7, 2023
@ambv ambv added the needs backport to 3.11 only security fixes label Feb 7, 2023
@miss-islington
Copy link
Contributor

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

@miss-islington
Copy link
Contributor

Sorry, @MatthieuDartiailh and @ambv, I could not cleanly backport this to 3.11 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker ae62bddaf81176a7e55f95f18d55621c9c46c23d 3.11

@MatthieuDartiailh MatthieuDartiailh deleted the pyeval_evalcodeex_default_support branch February 7, 2023 09:35
ambv pushed a commit to ambv/cpython that referenced this pull request Feb 7, 2023
…CodeEx for 3.11+ (pythonGH-101127)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
(cherry picked from commit ae62bdd)

Co-authored-by: Matthieu Dartiailh <m.dartiailh@gmail.com>
@bedevere-bot
Copy link

GH-101636 is a backport of this pull request to the 3.11 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label Feb 7, 2023
ambv added a commit to ambv/cpython that referenced this pull request Feb 7, 2023
pablogsal pushed a commit that referenced this pull request Feb 7, 2023
… for 3.11+ (GH-101127) (#101636)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Matthieu Dartiailh <m.dartiailh@gmail.com>
globals,
locals,
c_args,
c_args_len,
Copy link
Contributor

Choose a reason for hiding this comment

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

@ambv Looks like there are compiler warnings. See L-3152

Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch, looks like PyEval_EvalCodeEx lists those arguments simply as ints. I'll convert this code to do the same.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nikita reported this as GH-101656.

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.

6 participants