From cc026df591c966a4e8b9c98c1e74f82759e8da6d Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 24 Aug 2023 19:25:47 +0200 Subject: [PATCH] gh-107149: Make PyUnstable_ExecutableKinds public Move PyUnstable_ExecutableKinds and associated macros from the internal C API to the public C API. Rename constants: replace "PY_" prefix with "PyUnstable_" prefix. --- Include/cpython/pyframe.h | 8 ++++++++ Include/internal/pycore_frame.h | 8 -------- Python/frame.c | 12 ++++++------ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Include/cpython/pyframe.h b/Include/cpython/pyframe.h index 0e2afff925e31f..c5adbbe4868f69 100644 --- a/Include/cpython/pyframe.h +++ b/Include/cpython/pyframe.h @@ -33,3 +33,11 @@ PyAPI_FUNC(int) PyUnstable_InterpreterFrame_GetLasti(struct _PyInterpreterFrame /* Returns the currently executing line number, or -1 if there is no line number. * Does not raise an exception. */ PyAPI_FUNC(int) PyUnstable_InterpreterFrame_GetLine(struct _PyInterpreterFrame *frame); + +#define PyUnstable_EXECUTABLE_KIND_SKIP 0 +#define PyUnstable_EXECUTABLE_KIND_PY_FUNCTION 1 +#define PyUnstable_EXECUTABLE_KIND_BUILTIN_FUNCTION 3 +#define PyUnstable_EXECUTABLE_KIND_METHOD_DESCRIPTOR 4 +#define PyUnstable_EXECUTABLE_KINDS 5 + +PyAPI_DATA(const PyTypeObject *) const PyUnstable_ExecutableKinds[PyUnstable_EXECUTABLE_KINDS+1]; diff --git a/Include/internal/pycore_frame.h b/Include/internal/pycore_frame.h index ae77367f6a3c9b..c8fad1562d8443 100644 --- a/Include/internal/pycore_frame.h +++ b/Include/internal/pycore_frame.h @@ -311,14 +311,6 @@ PyGenObject *_PyFrame_GetGenerator(_PyInterpreterFrame *frame) return (PyGenObject *)(((char *)frame) - offset_in_gen); } -#define PY_EXECUTABLE_KIND_SKIP 0 -#define PY_EXECUTABLE_KIND_PY_FUNCTION 1 -#define PY_EXECUTABLE_KIND_BUILTIN_FUNCTION 3 -#define PY_EXECUTABLE_KIND_METHOD_DESCRIPTOR 4 -#define PY_EXECUTABLE_KINDS 5 - -PyAPI_DATA(const PyTypeObject *) const PyUnstable_ExecutableKinds[PY_EXECUTABLE_KINDS+1]; - #ifdef __cplusplus } #endif diff --git a/Python/frame.c b/Python/frame.c index fbfa54398c72b6..b483903fdf3018 100644 --- a/Python/frame.c +++ b/Python/frame.c @@ -167,10 +167,10 @@ PyUnstable_InterpreterFrame_GetLine(_PyInterpreterFrame *frame) return PyCode_Addr2Line(_PyFrame_GetCode(frame), addr); } -const PyTypeObject *const PyUnstable_ExecutableKinds[PY_EXECUTABLE_KINDS+1] = { - [PY_EXECUTABLE_KIND_SKIP] = &_PyNone_Type, - [PY_EXECUTABLE_KIND_PY_FUNCTION] = &PyCode_Type, - [PY_EXECUTABLE_KIND_BUILTIN_FUNCTION] = &PyMethod_Type, - [PY_EXECUTABLE_KIND_METHOD_DESCRIPTOR] = &PyMethodDescr_Type, - [PY_EXECUTABLE_KINDS] = NULL, +const PyTypeObject *const PyUnstable_ExecutableKinds[PyUnstable_EXECUTABLE_KINDS+1] = { + [PyUnstable_EXECUTABLE_KIND_SKIP] = &_PyNone_Type, + [PyUnstable_EXECUTABLE_KIND_PY_FUNCTION] = &PyCode_Type, + [PyUnstable_EXECUTABLE_KIND_BUILTIN_FUNCTION] = &PyMethod_Type, + [PyUnstable_EXECUTABLE_KIND_METHOD_DESCRIPTOR] = &PyMethodDescr_Type, + [PyUnstable_EXECUTABLE_KINDS] = NULL, };