(Contributed by Victor Stinner in :issue:`39573`.)
-* The ``<Python.h>`` header file no longer includes ``<stdlib.h>``. C
- extensions using ``<stdlib.h>`` must now include it explicitly.
- The system ``<stdlib.h>`` header provides functions like:
- ``malloc()``/``free()``, ``getenv()``, ``strtol()``, ``abs()``, ``strtol()``,
- ``exit()`` and ``abort()``.
- (Contributed by Victor Stinner in :issue:`45434`.)
-
-* The ``<Python.h>`` header file no longer includes ``<stdio.h>`` if the
- ``Py_LIMITED_API`` macro is defined. Functions expecting ``FILE*`` are
- excluded from the limited C API (:pep:`384`). C extensions using
- ``<stdio.h>`` must now include it explicitly. The system ``<stdio.h>``
- header provides functions like ``printf()`` and ``fopen()``.
+* ``<Python.h>`` no longer includes the header files ``<stdlib.h>``,
+ ``<stdio.h>``, ``<errno.h>`` and ``<string.h>`` when the ``Py_LIMITED_API``
+ macro is set to ``0x030b0000`` (Python 3.11) or higher. C extensions should
+ explicitly include the header files after ``#include <Python.h>``.
(Contributed by Victor Stinner in :issue:`45434`.)
* The non-limited API files ``cellobject.h``, ``classobject.h``, ``context.h``,
# define _SGI_MP_SOURCE
#endif
-#include <string.h> // memcpy()
-#ifndef Py_LIMITED_API
+// stdlib.h, stdio.h, errno.h and string.h headers are not used by Python
+// headers, but kept for backward compatibility. They are excluded from the
+// limited C API of Python 3.11.
+#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
+# include <stdlib.h>
# include <stdio.h> // FILE*
-#endif
-#ifdef HAVE_ERRNO_H
# include <errno.h> // errno
+# include <string.h> // memcpy()
#endif
#ifndef MS_WINDOWS
# include <unistd.h>
# define Py_LOCAL_INLINE(type) static inline type
#endif
-/* Py_MEMCPY is kept for backwards compatibility,
- * see https://bugs.python.org/issue28126 */
-#define Py_MEMCPY memcpy
+// bpo-28126: Py_MEMCPY is kept for backwards compatibility,
+#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
+# define Py_MEMCPY memcpy
+#endif
#ifdef HAVE_IEEEFP_H
#include <ieeefp.h> /* needed for 'finite' declaration on some platforms */
-The ``<Python.h>`` header file no longer includes ``<stdlib.h>``. C
-extensions using ``<stdlib.h>`` must now include it explicitly.
-The system ``<stdlib.h>`` header provides functions like:
-``malloc()``/``free()``, ``getenv()``, ``strtol()``, ``abs()``, ``strtol()``,
-``exit()`` and ``abort()``.
+``<Python.h>`` no longer includes the header files ``<stdlib.h>``,
+``<stdio.h>``, ``<errno.h>`` and ``<string.h>`` when the ``Py_LIMITED_API``
+macro is set to ``0x030b0000`` (Python 3.11) or higher. C extensions should
+explicitly include the header files after ``#include <Python.h>``.
Patch by Victor Stinner.
+++ /dev/null
-The ``<Python.h>`` header file no longer includes ``<stdio.h>`` if the
-``Py_LIMITED_API`` macro is defined. Functions expecting ``FILE*`` are excluded
-from the limited C API (:pep:`384`). C extensions using ``<stdio.h>`` must now
-include it explicitly.
-Patch by Victor Stinner.
-
/* Use this file as a template to start implementing a module that
also declares object types. All occurrences of 'Xxo' should be changed
to something reasonable for your objects. After that, all other
pass
*/
-#define Py_LIMITED_API 0x030a0000
+#define Py_LIMITED_API 0x030b0000
#include "Python.h"