Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0d499c7

Browse filesBrowse 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
Copy full SHA for 0d499c7

File tree

2 files changed

+4
-3
lines changed
Filter options

2 files changed

+4
-3
lines changed

‎Include/pymacro.h

Copy file name to clipboardExpand all lines: Include/pymacro.h
+3-2Lines 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

Copy file name to clipboardExpand all lines: Python/modsupport.c
+1-1Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.