From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Sat, 13 Jul 2024 21:31:30 +0000 (+0200) Subject: [3.13] gh-120642: Move _PyCode_CODE() to the internal C API (GH-121644) (#121729) X-Git-Tag: v3.13.0b4~62 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=48a96d23a837139fe533d085eafb7750e8144c83;p=thirdparty%2FPython%2Fcpython.git [3.13] gh-120642: Move _PyCode_CODE() to the internal C API (GH-121644) (#121729) gh-120642: Move _PyCode_CODE() to the internal C API (GH-121644) Move _PyCode_CODE() and _PyCode_NBYTES() macros to the internal C API since they use _Py_CODEUNIT which is only part of the internal C API. (cherry picked from commit a2bec77d25b11f50362a7117223f6d1d5029a909) Co-authored-by: Victor Stinner --- diff --git a/Include/cpython/code.h b/Include/cpython/code.h index 07ed5200a59d..58d93fcfc106 100644 --- a/Include/cpython/code.h +++ b/Include/cpython/code.h @@ -194,9 +194,6 @@ Py_DEPRECATED(3.13) static inline int PyCode_GetFirstFree(PyCodeObject *op) { return PyUnstable_Code_GetFirstFree(op); } -#define _PyCode_CODE(CO) _Py_RVALUE((_Py_CODEUNIT *)(CO)->co_code_adaptive) -#define _PyCode_NBYTES(CO) (Py_SIZE(CO) * (Py_ssize_t)sizeof(_Py_CODEUNIT)) - /* Unstable public interface */ PyAPI_FUNC(PyCodeObject *) PyUnstable_Code_New( int, int, int, int, int, PyObject *, PyObject *, diff --git a/Include/internal/pycore_code.h b/Include/internal/pycore_code.h index 48ff2701c847..c3553dfa3314 100644 --- a/Include/internal/pycore_code.h +++ b/Include/internal/pycore_code.h @@ -30,6 +30,9 @@ typedef union { _Py_BackoffCounter counter; // First cache entry of specializable op } _Py_CODEUNIT; +#define _PyCode_CODE(CO) _Py_RVALUE((_Py_CODEUNIT *)(CO)->co_code_adaptive) +#define _PyCode_NBYTES(CO) (Py_SIZE(CO) * (Py_ssize_t)sizeof(_Py_CODEUNIT)) + /* These macros only remain defined for compatibility. */ #define _Py_OPCODE(word) ((word).op.code)