diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst index 136fe901ce39fb..b64cfc51f75701 100644 --- a/Doc/whatsnew/3.13.rst +++ b/Doc/whatsnew/3.13.rst @@ -1191,17 +1191,6 @@ Porting to Python 3.13 also the ``HAVE_IEEEFP_H`` macro. (Contributed by Victor Stinner in :gh:`108765`.) -* ``Python.h`` no longer includes the ```` standard header file. If - needed, it should now be included explicitly. For example, it provides the - functions: ``read()``, ``write()``, ``close()``, ``isatty()``, ``lseek()``, - ``getpid()``, ``getcwd()``, ``sysconf()``, ``getpagesize()``, ``alarm()`` and - ``pause()``. - As a consequence, ``_POSIX_SEMAPHORES`` and ``_POSIX_THREADS`` macros are no - longer defined by ``Python.h``. The ``HAVE_UNISTD_H`` and ``HAVE_PTHREAD_H`` - macros defined by ``Python.h`` can be used to decide if ```` and - ```` header files can be included. - (Contributed by Victor Stinner in :gh:`108765`.) - * ``Python.h`` no longer includes these standard header files: ````, ```` and ````. If needed, they should now be included explicitly. For example, ```` provides the ``clock()`` and @@ -1210,13 +1199,6 @@ Porting to Python 3.13 and ``setitimer()`` functions. (Contributed by Victor Stinner in :gh:`108765`.) -* ``Python.h`` no longer includes the ```` standard header file. If - needed, it should now be included explicitly. For example, it provides - ``isalpha()`` and ``tolower()`` functions which are locale dependent. Python - provides locale independent functions, like :c:func:`!Py_ISALPHA` and - :c:func:`!Py_TOLOWER`. - (Contributed by Victor Stinner in :gh:`108765`.) - * If the :c:macro:`Py_LIMITED_API` macro is defined, :c:macro:`!Py_BUILD_CORE`, :c:macro:`!Py_BUILD_CORE_BUILTIN` and :c:macro:`!Py_BUILD_CORE_MODULE` macros are now undefined by ````. diff --git a/Include/Python.h b/Include/Python.h index a1f26afbb12256..196751c3201e62 100644 --- a/Include/Python.h +++ b/Include/Python.h @@ -26,15 +26,24 @@ # include // ssize_t #endif -// errno.h, stdio.h, stdlib.h and string.h headers are no longer used by -// Python, but kept for backward compatibility (avoid compiler warnings). -// They are no longer included by limited C API version 3.11 and newer. +// , , and headers are no longer used +// by Python, but kept for the backward compatibility of existing third party C +// extensions. They are not included by limited C API version 3.11 and newer. +// +// The and headers are not included by limited C API +// version 3.13 and newer. #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 # include // errno # include // FILE* # include // getenv() # include // memcpy() #endif +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030d0000 +# include // tolower() +# ifndef MS_WINDOWS +# include // close() +# endif +#endif // Include Python header files diff --git a/Misc/NEWS.d/next/C API/2023-11-13-17-57-11.gh-issue-112026.WJLJcI.rst b/Misc/NEWS.d/next/C API/2023-11-13-17-57-11.gh-issue-112026.WJLJcI.rst new file mode 100644 index 00000000000000..deb82ff7af7d54 --- /dev/null +++ b/Misc/NEWS.d/next/C API/2023-11-13-17-57-11.gh-issue-112026.WJLJcI.rst @@ -0,0 +1,3 @@ +Add again ```` and ```` includes in ``Python.h``, but +don't include them in the limited C API version 3.13 and newer. Patch by +Victor Stinner.