Skip to content

Commit 0d499c7

Browse files
authored
gh-128629: Add _Py_PACK_VERSION for CPython's own definitions (GH-134247)
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)`.
1 parent 469a564 commit 0d499c7

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

Include/pymacro.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,12 +231,13 @@
231231
// "comparison of unsigned expression in '< 0' is always false".
232232
#define _Py_IS_TYPE_SIGNED(type) ((type)(-1) <= 0)
233233

234-
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030E0000 // 3.14
235234
// Version helpers. These are primarily macros, but have exported equivalents.
235+
#define _Py_PACK_VERSION(X, Y) _Py_PACK_FULL_VERSION(X, Y, 0, 0, 0)
236+
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 14)
236237
PyAPI_FUNC(uint32_t) Py_PACK_FULL_VERSION(int x, int y, int z, int level, int serial);
237238
PyAPI_FUNC(uint32_t) Py_PACK_VERSION(int x, int y);
238239
#define Py_PACK_FULL_VERSION _Py_PACK_FULL_VERSION
239-
#define Py_PACK_VERSION(X, Y) Py_PACK_FULL_VERSION(X, Y, 0, 0, 0)
240+
#define Py_PACK_VERSION _Py_PACK_VERSION
240241
#endif // Py_LIMITED_API < 3.14
241242

242243

Python/modsupport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,5 +669,5 @@ Py_PACK_FULL_VERSION(int x, int y, int z, int level, int serial)
669669
uint32_t
670670
Py_PACK_VERSION(int x, int y)
671671
{
672-
return Py_PACK_FULL_VERSION(x, y, 0, 0, 0);
672+
return _Py_PACK_VERSION(x, y);
673673
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy