]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-128629: Add _Py_PACK_VERSION for CPython's own definitions (GH-134247)
authorPetr Viktorin <encukou@gmail.com>
Wed, 28 May 2025 13:24:40 +0000 (15:24 +0200)
committerGitHub <noreply@github.com>
Wed, 28 May 2025 13:24:40 +0000 (15:24 +0200)
Add _Py_PACK_VERSION for CPython's own definitions

Py_PACK_VERSION was added to limited API in 3.14, so if
Py_LIMITED_API is lower, the macro can't be used.
Add a private version that can be used in CPython headers
for checks like `Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 14)`.

Include/pymacro.h
Python/modsupport.c

index 218987a80b0d913fd1ffbd232d5a4d7a8856d674..d410645034d84826d988b24c3a9d7e5abcd45bda 100644 (file)
 // "comparison of unsigned expression in '< 0' is always false".
 #define _Py_IS_TYPE_SIGNED(type) ((type)(-1) <= 0)
 
-#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030E0000 // 3.14
 // Version helpers. These are primarily macros, but have exported equivalents.
+#define _Py_PACK_VERSION(X, Y) _Py_PACK_FULL_VERSION(X, Y, 0, 0, 0)
+#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 14)
 PyAPI_FUNC(uint32_t) Py_PACK_FULL_VERSION(int x, int y, int z, int level, int serial);
 PyAPI_FUNC(uint32_t) Py_PACK_VERSION(int x, int y);
 #define Py_PACK_FULL_VERSION _Py_PACK_FULL_VERSION
-#define Py_PACK_VERSION(X, Y) Py_PACK_FULL_VERSION(X, Y, 0, 0, 0)
+#define Py_PACK_VERSION _Py_PACK_VERSION
 #endif // Py_LIMITED_API < 3.14
 
 
index 2caf595949d52f034f0248eb87258f175893d755..437ad412027e28ebbb17ac25c91af71d5172c800 100644 (file)
@@ -669,5 +669,5 @@ Py_PACK_FULL_VERSION(int x, int y, int z, int level, int serial)
 uint32_t
 Py_PACK_VERSION(int x, int y)
 {
-    return Py_PACK_FULL_VERSION(x, y, 0, 0, 0);
+    return _Py_PACK_VERSION(x, y);
 }