Skip to content

Navigation Menu

Sign in
Appearance settings

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

Provide feedback

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

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0c26dbd

Browse filesBrowse files
authored
gh-133079: Remove Py_C_RECURSION_LIMIT & PyThreadState.c_recursion_remaining (GH-133080)
Both were added in 3.13, are undocumented, and don't make sense in 3.14 due to changes in the stack overflow detection machinery (gh-112282). PEP 387 exception for skipping a deprecation period: python/steering-council#288
1 parent 208d06f commit 0c26dbd
Copy full SHA for 0c26dbd

File tree

Expand file treeCollapse file tree

5 files changed

+12
-6
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+12
-6
lines changed

‎Doc/whatsnew/3.14.rst

Copy file name to clipboardExpand all lines: Doc/whatsnew/3.14.rst
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2280,3 +2280,10 @@ Removed
22802280
* Remove the private ``_Py_InitializeMain()`` function. It was a
22812281
:term:`provisional API` added to Python 3.8 by :pep:`587`.
22822282
(Contributed by Victor Stinner in :gh:`129033`.)
2283+
2284+
* The undocumented APIs :c:macro:`!Py_C_RECURSION_LIMIT` and
2285+
:c:member:`!PyThreadState.c_recursion_remaining`, added in 3.13, are removed
2286+
without a deprecation period.
2287+
Please use :c:func:`Py_EnterRecursiveCall` to guard against runaway recursion
2288+
in C code.
2289+
(Removed in :gh:`133079`, see also :gh:`130396`.)

‎Include/cpython/pystate.h

Copy file name to clipboardExpand all lines: Include/cpython/pystate.h
-4Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,6 @@ struct _ts {
118118

119119
int py_recursion_remaining;
120120
int py_recursion_limit;
121-
122-
int c_recursion_remaining; /* Retained for backwards compatibility. Do not use */
123121
int recursion_headroom; /* Allow 50 more calls to handle any errors. */
124122

125123
/* 'tracing' keeps track of the execution depth when tracing/profiling.
@@ -210,8 +208,6 @@ struct _ts {
210208
_PyRemoteDebuggerSupport remote_debugger_support;
211209
};
212210

213-
# define Py_C_RECURSION_LIMIT 5000
214-
215211
/* other API */
216212

217213
/* Similar to PyThreadState_Get(), but don't issue a fatal error
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
The undocumented APIs :c:macro:`!Py_C_RECURSION_LIMIT` and
2+
:c:member:`!PyThreadState.c_recursion_remaining`, added in 3.13, are removed
3+
without a deprecation period.

‎Python/pystate.c

Copy file name to clipboardExpand all lines: Python/pystate.c
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1559,7 +1559,6 @@ init_threadstate(_PyThreadStateImpl *_tstate,
15591559

15601560
tstate->py_recursion_limit = interp->ceval.recursion_limit;
15611561
tstate->py_recursion_remaining = interp->ceval.recursion_limit;
1562-
tstate->c_recursion_remaining = 2;
15631562
tstate->exc_info = &tstate->exc_state;
15641563

15651564
// PyGILState_Release must not try to delete this thread state.

‎Python/vm-state.md

Copy file name to clipboardExpand all lines: Python/vm-state.md
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ It will be more complex in the JIT.
7373

7474
Another important piece of VM state is the **thread state**, held in `tstate`.
7575
The current frame pointer, `frame`, is always equal to `tstate->current_frame`.
76-
The thread state also holds the exception state (`tstate->exc_info`) and the recursion counters (`tstate->c_recursion_remaining` and `tstate->py_recursion_remaining`).
76+
The thread state also holds the exception state (`tstate->exc_info`) and
77+
recursion tracking data (`tstate->py_recursion_remaining`, `tstate->c_stack*`).
7778

7879
The thread state is also used to access the **interpreter state** (`tstate->interp`), which is important since the "eval breaker" flags are stored there (`tstate->interp->ceval.eval_breaker`, an "atomic" variable), as well as the "PEP 523 function" (`tstate->interp->eval_frame`).
7980
The interpreter state also holds the optimizer state (`optimizer` and some counters).

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.