Skip to content
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

Missing whitespaces when using Py_CheckRecursiveCall & co #126035

Closed
picnixz opened this issue Oct 27, 2024 · 1 comment
Closed

Missing whitespaces when using Py_CheckRecursiveCall & co #126035

picnixz opened this issue Oct 27, 2024 · 1 comment
Labels
3.12 bugs and security fixes 3.13 bugs and security fixes 3.14 new features, bugs and security fixes extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error

Comments

@picnixz
Copy link
Contributor

picnixz commented Oct 27, 2024

Bug report

Bug description:

The message must be prefixed by a whitespace since _Py_CheckRecursiveCall directly appends them to "maximum recursion depth exceeded":

cpython/Python/ceval.c

Lines 329 to 335 in dc76a4a

if (tstate->c_recursion_remaining <= 0) {
tstate->recursion_headroom++;
_PyErr_Format(tstate, PyExc_RecursionError,
"maximum recursion depth exceeded%s",
where);
tstate->recursion_headroom--;
++tstate->c_recursion_remaining;
.

Alternatively, we could make it so that a whitespace is automatically added and strip leading whitespaces if the "where" is the empty string (we wouldn't strip whitespaces in custom messages though I think).

For now, I'll just add the missing whitespaces where it should be.

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs

@picnixz picnixz added the type-bug An unexpected behavior, bug, or error label Oct 27, 2024
@picnixz picnixz added extension-modules C modules in the Modules dir 3.12 bugs and security fixes 3.14 new features, bugs and security fixes 3.13 bugs and security fixes labels Oct 27, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Oct 27, 2024
…essages (pythonGH-126036)

(cherry picked from commit 19e93e2)

Co-authored-by: Bénédikt Tran <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Oct 27, 2024
…essages (pythonGH-126036)

(cherry picked from commit 19e93e2)

Co-authored-by: Bénédikt Tran <[email protected]>
erlend-aasland pushed a commit that referenced this issue Oct 27, 2024
…messages (GH-126036) (#126059)

(cherry picked from commit 19e93e2)

Co-authored-by: Bénédikt Tran <[email protected]>
erlend-aasland pushed a commit that referenced this issue Oct 27, 2024
…messages (GH-126036) (#126058)

(cherry picked from commit 19e93e2)

Co-authored-by: Bénédikt Tran <[email protected]>
@picnixz
Copy link
Contributor Author

picnixz commented Oct 27, 2024

Closing since completed and backported.

@picnixz picnixz closed this as completed Oct 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.12 bugs and security fixes 3.13 bugs and security fixes 3.14 new features, bugs and security fixes extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant