Skip to content

Commit 5dfa606

Browse files
authored
gh-155561: Build most _testlimitedcapi files with Py_TARGET_ABI3T (#155570)
The following files are not build with Py_TARGET_ABI3T: * Modules/_testlimitedcapi.c * Modules/_testlimitedcapi/heaptype_relative.c * Modules/_testlimitedcapi/vectorcall_limited.c
1 parent 3f99ebe commit 5dfa606

16 files changed

Lines changed: 60 additions & 25 deletions

File tree

Modules/_testlimitedcapi.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@
55
* standard Python regression test, via Lib/test/test_capi.py.
66
*/
77

8+
#include "pyconfig.h" // Py_GIL_DISABLED
9+
10+
#ifdef Py_GIL_DISABLED
11+
// Cannot test the limited C API
12+
#else
13+
// Use the oldest limited C API version
14+
# define Py_LIMITED_API 0x03020000
15+
#endif
16+
817
#include "_testlimitedcapi/parts.h"
918

1019
static PyMethodDef TestMethods[] = {

Modules/_testlimitedcapi/capsule.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#include "parts.h"
22

3+
#include <stdlib.h> // free()
4+
5+
36
static void
47
capsule_destructor(PyObject *op)
58
{

Modules/_testlimitedcapi/codec.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#include "pyconfig.h" // Py_GIL_DISABLED
2-
3-
// Need limited C API version 3.5 for PyCodec_NameReplaceErrors()
4-
#if !defined(Py_GIL_DISABLED) && !defined(Py_LIMITED_API)
2+
#ifdef Py_GIL_DISABLED
3+
# define Py_TARGET_ABI3T 0x030f0000
4+
#else
5+
// Need limited C API version 3.5 for PyCodec_NameReplaceErrors()
56
# define Py_LIMITED_API 0x03050000
67
#endif
78

Modules/_testlimitedcapi/file.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#include "pyconfig.h" // Py_GIL_DISABLED
2-
#ifndef Py_GIL_DISABLED
2+
#ifdef Py_GIL_DISABLED
3+
# define Py_TARGET_ABI3T 0x030f0000
4+
#else
35
// Need limited C API 3.13 for PyLong_AsInt()
46
# define Py_LIMITED_API 0x030d0000
57
#endif

Modules/_testlimitedcapi/heaptype_relative.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
// Need limited C API version 3.15 for _DuringGC functions
21
#include "pyconfig.h" // Py_GIL_DISABLED
3-
#if !defined(Py_GIL_DISABLED) && !defined(Py_LIMITED_API)
2+
#ifdef Py_GIL_DISABLED
3+
// Cannot test the limited C API
4+
#else
5+
// Need limited C API version 3.15 for _DuringGC functions
46
# define Py_LIMITED_API 0x030f0000
57
#endif
68

Modules/_testlimitedcapi/import.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
// Need limited C API version 3.13 for PyImport_AddModuleRef()
21
#include "pyconfig.h" // Py_GIL_DISABLED
3-
#if !defined(Py_GIL_DISABLED) && !defined(Py_LIMITED_API)
2+
#ifdef Py_GIL_DISABLED
3+
# define Py_TARGET_ABI3T 0x030f0000
4+
#else
5+
// Need limited C API version 3.13 for PyImport_AddModuleRef()
46
# define Py_LIMITED_API 0x030d0000
57
#endif
68

Modules/_testlimitedcapi/list.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
// Need limited C API version 3.13 for PyList_GetItemRef()
21
#include "pyconfig.h" // Py_GIL_DISABLED
3-
#if !defined(Py_GIL_DISABLED) && !defined(Py_LIMITED_API)
2+
#ifdef Py_GIL_DISABLED
3+
# define Py_TARGET_ABI3T 0x030f0000
4+
#else
5+
// Need limited C API version 3.13 for PyList_GetItemRef()
46
# define Py_LIMITED_API 0x030d0000
57
#endif
68

Modules/_testlimitedcapi/long.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#include "pyconfig.h" // Py_GIL_DISABLED
2-
#ifndef Py_GIL_DISABLED
2+
#ifdef Py_GIL_DISABLED
3+
# define Py_TARGET_ABI3T 0x030f0000
4+
#else
35
// Need limited C API 3.14 to test PyLong_AsInt64()
46
# define Py_LIMITED_API 0x030e0000
57
#endif

Modules/_testlimitedcapi/object.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
// Need limited C API version 3.13 for Py_GetConstant()
21
#include "pyconfig.h" // Py_GIL_DISABLED
3-
#if !defined(Py_GIL_DISABLED) && !defined(Py_LIMITED_API)
2+
#ifdef Py_GIL_DISABLED
3+
# define Py_TARGET_ABI3T 0x030f0000
4+
#else
5+
// Need limited C API version 3.13 for Py_GetConstant()
46
# define Py_LIMITED_API 0x030d0000
57
#endif
68

Modules/_testlimitedcapi/parts.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
#include "pyconfig.h" // Py_GIL_DISABLED
88

99
// Use the limited C API
10-
#if !defined(Py_GIL_DISABLED) && !defined(Py_LIMITED_API)
11-
// need limited C API version 3.5 for PyModule_AddFunctions()
10+
#ifdef Py_GIL_DISABLED
11+
// Cannot test the limited C API
12+
#elif !defined(Py_LIMITED_API)
13+
// Need limited C API version 3.5 for PyModule_AddFunctions()
1214
# define Py_LIMITED_API 0x03050000
1315
#endif
1416

0 commit comments

Comments
 (0)