summaryrefslogtreecommitdiff
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-05-04 13:30:23 +0200
committerGitHub <noreply@github.com>2022-05-04 13:30:23 +0200
commitd716a0dfe2d1029111db393afaecdb04cc4093de (patch)
tree2644817d65b365bf1dd2872661948d1b564bff32 /Python/pythonrun.c
parent14243369b5f80613628a565c224bba7fb3fcacd8 (diff)
downloadcpython-git-d716a0dfe2d1029111db393afaecdb04cc4093de.tar.gz
Use static inline function Py_EnterRecursiveCall() (#91988)
Currently, calling Py_EnterRecursiveCall() and Py_LeaveRecursiveCall() may use a function call or a static inline function call, depending if the internal pycore_ceval.h header file is included or not. Use a different name for the static inline function to ensure that the static inline function is always used in Python internals for best performance. Similar approach than PyThreadState_GET() (function call) and _PyThreadState_GET() (static inline function). * Rename _Py_EnterRecursiveCall() to _Py_EnterRecursiveCallTstate() * Rename _Py_LeaveRecursiveCall() to _Py_LeaveRecursiveCallTstate() * pycore_ceval.h: Rename Py_EnterRecursiveCall() to _Py_EnterRecursiveCall() and Py_LeaveRecursiveCall() and _Py_LeaveRecursiveCall()
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r--Python/pythonrun.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 769c34ea16..f12b9f6e95 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -13,6 +13,7 @@
#include "Python.h"
#include "pycore_ast.h" // PyAST_mod2obj
+#include "pycore_ceval.h" // _Py_EnterRecursiveCall
#include "pycore_compile.h" // _PyAST_Compile()
#include "pycore_interp.h" // PyInterpreterState.importlib
#include "pycore_object.h" // _PyDebug_PrintTotalRefs()
@@ -1268,13 +1269,13 @@ print_chained(struct exception_print_context* ctx, PyObject *value,
{
PyObject *f = ctx->file;
- if (Py_EnterRecursiveCall(" in print_chained") < 0) {
+ if (_Py_EnterRecursiveCall(" in print_chained") < 0) {
return -1;
}
bool need_close = ctx->need_close;
int res = print_exception_recursive(ctx, value);
ctx->need_close = need_close;
- Py_LeaveRecursiveCall();
+ _Py_LeaveRecursiveCall();
if (res < 0) {
return -1;
}
@@ -1445,11 +1446,11 @@ print_exception_group(struct exception_print_context *ctx, PyObject *value)
PyObject *exc = PyTuple_GET_ITEM(excs, i);
if (!truncated) {
- if (Py_EnterRecursiveCall(" in print_exception_group") != 0) {
+ if (_Py_EnterRecursiveCall(" in print_exception_group") != 0) {
return -1;
}
int res = print_exception_recursive(ctx, exc);
- Py_LeaveRecursiveCall();
+ _Py_LeaveRecursiveCall();
if (res < 0) {
return -1;
}