summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2023-10-17 01:05:20 (GMT)
committerGitHub <noreply@github.com>2023-10-17 01:05:20 (GMT)
commit37bd8726b87c1c41f58cef031f5b6d5f900d265b (patch)
tree04ce00a1525ca7e45aed45dffc28c8bce577aba8
parentcc71cc925662cb089b5c6fe17df00d00045dfd71 (diff)
downloadcpython-37bd8726b87c1c41f58cef031f5b6d5f900d265b.zip
cpython-37bd8726b87c1c41f58cef031f5b6d5f900d265b.tar.gz
cpython-37bd8726b87c1c41f58cef031f5b6d5f900d265b.tar.bz2
gh-85283: Build errno and _ctypes_test with limited C API (#110955)
_testimportmultiple is now built with limited C API version 3.2.
-rw-r--r--Doc/whatsnew/3.13.rst4
-rw-r--r--Misc/NEWS.d/next/Build/2023-10-17-01-56-11.gh-issue-85283.V156T2.rst5
-rw-r--r--Modules/_ctypes/_ctypes_test.c7
-rw-r--r--Modules/_testimportmultiple.c2
-rw-r--r--Modules/errnomodule.c67
5 files changed, 45 insertions, 40 deletions
diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst
index ec76659..a932be4 100644
--- a/Doc/whatsnew/3.13.rst
+++ b/Doc/whatsnew/3.13.rst
@@ -932,8 +932,8 @@ Build Changes
* Building CPython now requires a compiler with support for the C11 atomic
library, GCC built-in atomic functions, or MSVC interlocked intrinsics.
-* The ``_stat`` and ``_testimportmultiple`` C extensions are now built with the
- :ref:`limited C API <limited-c-api>`.
+* The ``errno``, ``_ctypes_test``, ``_stat`` and ``_testimportmultiple`` C
+ extensions are now built with the :ref:`limited C API <limited-c-api>`.
(Contributed by Victor Stinner in :gh:`85283`.)
diff --git a/Misc/NEWS.d/next/Build/2023-10-17-01-56-11.gh-issue-85283.V156T2.rst b/Misc/NEWS.d/next/Build/2023-10-17-01-56-11.gh-issue-85283.V156T2.rst
index 763e6b8..db48496 100644
--- a/Misc/NEWS.d/next/Build/2023-10-17-01-56-11.gh-issue-85283.V156T2.rst
+++ b/Misc/NEWS.d/next/Build/2023-10-17-01-56-11.gh-issue-85283.V156T2.rst
@@ -1,2 +1,3 @@
-The ``_testimportmultiple`` C extension is now built with the :ref:`limited
-C API <limited-c-api>`. Patch by Victor Stinner.
+The ``errno``, ``_ctypes_test`` and ``_testimportmultiple`` C extensions are
+now built with the :ref:`limited C API <limited-c-api>`. Patch by Victor
+Stinner.
diff --git a/Modules/_ctypes/_ctypes_test.c b/Modules/_ctypes/_ctypes_test.c
index ddfb2c8..11c7a6b 100644
--- a/Modules/_ctypes/_ctypes_test.c
+++ b/Modules/_ctypes/_ctypes_test.c
@@ -1,11 +1,12 @@
+#define Py_LIMITED_API 0x03060000
+
#include <Python.h>
+#include <stdlib.h> // qsort()
#ifdef MS_WIN32
-#include <windows.h>
+# include <windows.h>
#endif
-#include <stdlib.h> // qsort()
-
#define EXPORT(x) Py_EXPORTED_SYMBOL x
/* some functions handy for testing */
diff --git a/Modules/_testimportmultiple.c b/Modules/_testimportmultiple.c
index 01c519b..a13024d 100644
--- a/Modules/_testimportmultiple.c
+++ b/Modules/_testimportmultiple.c
@@ -4,7 +4,7 @@
* foo, bar), only the first one is called the same as the compiled file.
*/
-#define Py_LIMITED_API 0x030d0000
+#define Py_LIMITED_API 0x03020000
#include <Python.h>
diff --git a/Modules/errnomodule.c b/Modules/errnomodule.c
index 301ad83..25cd7e9 100644
--- a/Modules/errnomodule.c
+++ b/Modules/errnomodule.c
@@ -1,41 +1,44 @@
-
/* Errno module */
+// Need PyModuleDef_Slot added to limited C API version 3.5
+#define Py_LIMITED_API 0x03050000
+
#include "Python.h"
/* Windows socket errors (WSA*) */
#ifdef MS_WINDOWS
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN
-#endif
-#include <windows.h>
-/* The following constants were added to errno.h in VS2010 but have
- preferred WSA equivalents. */
-#undef EADDRINUSE
-#undef EADDRNOTAVAIL
-#undef EAFNOSUPPORT
-#undef EALREADY
-#undef ECONNABORTED
-#undef ECONNREFUSED
-#undef ECONNRESET
-#undef EDESTADDRREQ
-#undef EHOSTUNREACH
-#undef EINPROGRESS
-#undef EISCONN
-#undef ELOOP
-#undef EMSGSIZE
-#undef ENETDOWN
-#undef ENETRESET
-#undef ENETUNREACH
-#undef ENOBUFS
-#undef ENOPROTOOPT
-#undef ENOTCONN
-#undef ENOTSOCK
-#undef EOPNOTSUPP
-#undef EPROTONOSUPPORT
-#undef EPROTOTYPE
-#undef ETIMEDOUT
-#undef EWOULDBLOCK
+# ifndef WIN32_LEAN_AND_MEAN
+# define WIN32_LEAN_AND_MEAN
+# endif
+# include <windows.h>
+
+ // The following constants were added to errno.h in VS2010 but have
+ // preferred WSA equivalents.
+# undef EADDRINUSE
+# undef EADDRNOTAVAIL
+# undef EAFNOSUPPORT
+# undef EALREADY
+# undef ECONNABORTED
+# undef ECONNREFUSED
+# undef ECONNRESET
+# undef EDESTADDRREQ
+# undef EHOSTUNREACH
+# undef EINPROGRESS
+# undef EISCONN
+# undef ELOOP
+# undef EMSGSIZE
+# undef ENETDOWN
+# undef ENETRESET
+# undef ENETUNREACH
+# undef ENOBUFS
+# undef ENOPROTOOPT
+# undef ENOTCONN
+# undef ENOTSOCK
+# undef EOPNOTSUPP
+# undef EPROTONOSUPPORT
+# undef EPROTOTYPE
+# undef ETIMEDOUT
+# undef EWOULDBLOCK
#endif
/*