]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-120642: Move _PyCode_CODE() to the internal C API (GH-121644) (#121729)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sat, 13 Jul 2024 21:31:30 +0000 (23:31 +0200)
committerGitHub <noreply@github.com>
Sat, 13 Jul 2024 21:31:30 +0000 (21:31 +0000)
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 <vstinner@python.org>
Include/cpython/code.h
Include/internal/pycore_code.h

index 07ed5200a59d619d9a4baff8d14669db20c6a829..58d93fcfc1066bad2461c2f2d62c4cdc64a8f490 100644 (file)
@@ -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 *,
index 48ff2701c8471d0e30c30e7883a9cf63499f0bab..c3553dfa33147663560c7bc220a4796d557e54fa 100644 (file)
@@ -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)