From 28e4a394c442c506883b74e6cb7ff260a767d540 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 25 Nov 2025 16:59:28 +0100 Subject: [PATCH] gh-130396: Remove _Py_ReachedRecursionLimitWithMargin() function Move the private function to the internal C API (pycore_ceval.h). --- Include/cpython/object.h | 2 -- Include/internal/pycore_ceval.h | 4 ++++ Parser/parser.c | 1 + Tools/peg_generator/pegen/c_generator.py | 1 + 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Include/cpython/object.h b/Include/cpython/object.h index 130a105de42150..8693390aeda624 100644 --- a/Include/cpython/object.h +++ b/Include/cpython/object.h @@ -436,8 +436,6 @@ PyAPI_FUNC(void) _Py_NO_RETURN _PyObject_AssertFailed( PyAPI_FUNC(void) _PyTrash_thread_deposit_object(PyThreadState *tstate, PyObject *op); PyAPI_FUNC(void) _PyTrash_thread_destroy_chain(PyThreadState *tstate); -PyAPI_FUNC(int) _Py_ReachedRecursionLimitWithMargin(PyThreadState *tstate, int margin_count); - /* For backwards compatibility with the old trashcan mechanism */ #define Py_TRASHCAN_BEGIN(op, dealloc) #define Py_TRASHCAN_END diff --git a/Include/internal/pycore_ceval.h b/Include/internal/pycore_ceval.h index 2ae84be7b33966..fa2a67ff95734a 100644 --- a/Include/internal/pycore_ceval.h +++ b/Include/internal/pycore_ceval.h @@ -263,6 +263,10 @@ static inline int _Py_ReachedRecursionLimit(PyThreadState *tstate) { #endif } +extern int _Py_ReachedRecursionLimitWithMargin( + PyThreadState *tstate, + int margin_count); + static inline void _Py_LeaveRecursiveCall(void) { } diff --git a/Parser/parser.c b/Parser/parser.c index 53417fb2b72b10..648b3702d8ff71 100644 --- a/Parser/parser.c +++ b/Parser/parser.c @@ -1,5 +1,6 @@ // @generated by pegen from python.gram #include "pegen.h" +#include "pycore_ceval.h" #if defined(Py_DEBUG) && defined(Py_BUILD_CORE) # define D(x) if (p->debug) { x; } diff --git a/Tools/peg_generator/pegen/c_generator.py b/Tools/peg_generator/pegen/c_generator.py index ffa73a64f21cfe..a4e111972bdad5 100644 --- a/Tools/peg_generator/pegen/c_generator.py +++ b/Tools/peg_generator/pegen/c_generator.py @@ -31,6 +31,7 @@ EXTENSION_PREFIX = """\ #include "pegen.h" +#include "pycore_ceval.h" #if defined(Py_DEBUG) && defined(Py_BUILD_CORE) # define D(x) if (p->debug) { x; }