Skip to content

Commit 37bd872

Browse files
authored
gh-85283: Build errno and _ctypes_test with limited C API (#110955)
_testimportmultiple is now built with limited C API version 3.2.
1 parent cc71cc9 commit 37bd872

File tree

5 files changed

+45
-40
lines changed

5 files changed

+45
-40
lines changed

Doc/whatsnew/3.13.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -932,8 +932,8 @@ Build Changes
932932
* Building CPython now requires a compiler with support for the C11 atomic
933933
library, GCC built-in atomic functions, or MSVC interlocked intrinsics.
934934

935-
* The ``_stat`` and ``_testimportmultiple`` C extensions are now built with the
936-
:ref:`limited C API <limited-c-api>`.
935+
* The ``errno``, ``_ctypes_test``, ``_stat`` and ``_testimportmultiple`` C
936+
extensions are now built with the :ref:`limited C API <limited-c-api>`.
937937
(Contributed by Victor Stinner in :gh:`85283`.)
938938

939939

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
The ``_testimportmultiple`` C extension is now built with the :ref:`limited
2-
C API <limited-c-api>`. Patch by Victor Stinner.
1+
The ``errno``, ``_ctypes_test`` and ``_testimportmultiple`` C extensions are
2+
now built with the :ref:`limited C API <limited-c-api>`. Patch by Victor
3+
Stinner.

Modules/_ctypes/_ctypes_test.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
#define Py_LIMITED_API 0x03060000
2+
13
#include <Python.h>
24

5+
#include <stdlib.h> // qsort()
36
#ifdef MS_WIN32
4-
#include <windows.h>
7+
# include <windows.h>
58
#endif
69

7-
#include <stdlib.h> // qsort()
8-
910
#define EXPORT(x) Py_EXPORTED_SYMBOL x
1011

1112
/* some functions handy for testing */

Modules/_testimportmultiple.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* foo, bar), only the first one is called the same as the compiled file.
55
*/
66

7-
#define Py_LIMITED_API 0x030d0000
7+
#define Py_LIMITED_API 0x03020000
88

99
#include <Python.h>
1010

Modules/errnomodule.c

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,44 @@
1-
21
/* Errno module */
32

3+
// Need PyModuleDef_Slot added to limited C API version 3.5
4+
#define Py_LIMITED_API 0x03050000
5+
46
#include "Python.h"
57

68
/* Windows socket errors (WSA*) */
79
#ifdef MS_WINDOWS
8-
#ifndef WIN32_LEAN_AND_MEAN
9-
#define WIN32_LEAN_AND_MEAN
10-
#endif
11-
#include <windows.h>
12-
/* The following constants were added to errno.h in VS2010 but have
13-
preferred WSA equivalents. */
14-
#undef EADDRINUSE
15-
#undef EADDRNOTAVAIL
16-
#undef EAFNOSUPPORT
17-
#undef EALREADY
18-
#undef ECONNABORTED
19-
#undef ECONNREFUSED
20-
#undef ECONNRESET
21-
#undef EDESTADDRREQ
22-
#undef EHOSTUNREACH
23-
#undef EINPROGRESS
24-
#undef EISCONN
25-
#undef ELOOP
26-
#undef EMSGSIZE
27-
#undef ENETDOWN
28-
#undef ENETRESET
29-
#undef ENETUNREACH
30-
#undef ENOBUFS
31-
#undef ENOPROTOOPT
32-
#undef ENOTCONN
33-
#undef ENOTSOCK
34-
#undef EOPNOTSUPP
35-
#undef EPROTONOSUPPORT
36-
#undef EPROTOTYPE
37-
#undef ETIMEDOUT
38-
#undef EWOULDBLOCK
10+
# ifndef WIN32_LEAN_AND_MEAN
11+
# define WIN32_LEAN_AND_MEAN
12+
# endif
13+
# include <windows.h>
14+
15+
// The following constants were added to errno.h in VS2010 but have
16+
// preferred WSA equivalents.
17+
# undef EADDRINUSE
18+
# undef EADDRNOTAVAIL
19+
# undef EAFNOSUPPORT
20+
# undef EALREADY
21+
# undef ECONNABORTED
22+
# undef ECONNREFUSED
23+
# undef ECONNRESET
24+
# undef EDESTADDRREQ
25+
# undef EHOSTUNREACH
26+
# undef EINPROGRESS
27+
# undef EISCONN
28+
# undef ELOOP
29+
# undef EMSGSIZE
30+
# undef ENETDOWN
31+
# undef ENETRESET
32+
# undef ENETUNREACH
33+
# undef ENOBUFS
34+
# undef ENOPROTOOPT
35+
# undef ENOTCONN
36+
# undef ENOTSOCK
37+
# undef EOPNOTSUPP
38+
# undef EPROTONOSUPPORT
39+
# undef EPROTOTYPE
40+
# undef ETIMEDOUT
41+
# undef EWOULDBLOCK
3942
#endif
4043

4144
/*

0 commit comments

Comments
 (0)