Skip to content

3.11 regression: default arguments in PyEval_EvalCodeEx #101072

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

Closed
MatthieuDartiailh opened this issue Jan 16, 2023 · 3 comments
Closed

3.11 regression: default arguments in PyEval_EvalCodeEx #101072

MatthieuDartiailh opened this issue Jan 16, 2023 · 3 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) release-blocker type-bug An unexpected behavior, bug, or error

Comments

@MatthieuDartiailh
Copy link
Contributor

MatthieuDartiailh commented Jan 16, 2023

Bug report

3.11 Started using _PyFunction_FromConstructor inside PyEval_EvalCodeEx. #92173 reported that this caused issues when closures were involved because _PyFunction_FromConstructor discarded the closure found in PyFrameConstructor. This was fixed in #92175.

It turns out the same holds true for default arguments and default kw arguments as can be seen at https://github.com/python/cpython/blob/main/Objects/funcobject.c#L90-L91 and is a regression compared to 3.10.

The fix appears fairly simple but I would love to have some guidance as to where to add a test for it.

Your environment

  • CPython versions tested on: 3.11.0
  • Operating system and architecture: Windows x86-64

Linked PRs

@MatthieuDartiailh MatthieuDartiailh added the type-bug An unexpected behavior, bug, or error label Jan 16, 2023
@MatthieuDartiailh
Copy link
Contributor Author

@larryhastings This may be of interest since you authored #92175

@carljm
Copy link
Member

carljm commented Jan 20, 2023

The only usage of PyEval_EvalCodeEx within CPython is via builtin exec, which would never use these fields.

So the only context in which the regression matters is external use of PyEval_EvalCodeEx as part of the C API. So I suggest the test should go into test_capi.py (probably requiring a custom C test function in Modules/_testcapimodule.c).

EDIT: just realized you already have a PR and reached the same conclusion :)

ambv added a commit that referenced this issue Feb 7, 2023
…11+ (#101127)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
ambv pushed a commit to ambv/cpython that referenced this issue 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>
ambv added a commit to ambv/cpython that referenced this issue Feb 7, 2023
pablogsal pushed a commit that referenced this issue 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>
@MatthieuDartiailh
Copy link
Contributor Author

This can now be closed I believe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) release-blocker type-bug An unexpected behavior, bug, or error
Projects
Development

No branches or pull requests

5 participants