From dddca413f458fab4f3a4562329288676da9dc29c Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 1 Sep 2023 17:45:04 +0200 Subject: [PATCH] gh-108765: Python.h no longer includes --- Doc/whatsnew/3.13.rst | 4 ++++ Include/Python.h | 11 +++++------ .../2023-09-01-21-10-29.gh-issue-108765.eeXtYF.rst | 2 ++ Modules/grpmodule.c | 3 ++- Modules/mmapmodule.c | 1 + Modules/pwdmodule.c | 4 +++- Modules/selectmodule.c | 1 + 7 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 Misc/NEWS.d/next/C API/2023-09-01-21-10-29.gh-issue-108765.eeXtYF.rst diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst index d35d20ebb252936..571e37c4d50d67c 100644 --- a/Doc/whatsnew/3.13.rst +++ b/Doc/whatsnew/3.13.rst @@ -915,6 +915,10 @@ New Features Porting to Python 3.13 ---------------------- +* ``Python.h`` no longer includes the ```` standard header file. If + needed, it should now be included explicitly. + (Contributed by Victor Stinner in :gh:`108765`.) + Deprecated ---------- diff --git a/Include/Python.h b/Include/Python.h index 44f0fd3ee4b56b5..603726e30e5e2e6 100644 --- a/Include/Python.h +++ b/Include/Python.h @@ -25,14 +25,13 @@ #ifdef HAVE_STDDEF_H # include // size_t #endif -#ifndef MS_WINDOWS -# include // sysconf() +#ifdef HAVE_SYS_TYPES_H +# include // ssize_t #endif -// errno.h, stdio.h, stdlib.h and string.h headers are no longer used by Python -// headers, but kept for backward compatibility (no introduce new compiler -// warnings). They are not included by the limited C API version 3.11 and -// above. +// 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. #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 # include // errno # include // FILE* diff --git a/Misc/NEWS.d/next/C API/2023-09-01-21-10-29.gh-issue-108765.eeXtYF.rst b/Misc/NEWS.d/next/C API/2023-09-01-21-10-29.gh-issue-108765.eeXtYF.rst new file mode 100644 index 000000000000000..b26aab974a1f1a1 --- /dev/null +++ b/Misc/NEWS.d/next/C API/2023-09-01-21-10-29.gh-issue-108765.eeXtYF.rst @@ -0,0 +1,2 @@ +``Python.h`` no longer includes the ```` standard header file. If +needed, it should now be included explicitly. Patch by Victor Stinner. diff --git a/Modules/grpmodule.c b/Modules/grpmodule.c index f5709296334a8fa..20e83de84e8340f 100644 --- a/Modules/grpmodule.c +++ b/Modules/grpmodule.c @@ -4,7 +4,8 @@ #include "Python.h" #include "posixmodule.h" -#include +#include // getgrgid_r() +#include // sysconf() #include "clinic/grpmodule.c.h" /*[clinic input] diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c index c8cd7e59dbab500..3e5c80a492f420c 100644 --- a/Modules/mmapmodule.c +++ b/Modules/mmapmodule.c @@ -28,6 +28,7 @@ #include "pycore_fileutils.h" // _Py_stat_struct #include // offsetof() +#include // close() // to support MS_WINDOWS_SYSTEM OpenFileMappingA / CreateFileMappingA // need to be replaced with OpenFileMappingW / CreateFileMappingW diff --git a/Modules/pwdmodule.c b/Modules/pwdmodule.c index cc2e2a43893971d..f662cf63856c773 100644 --- a/Modules/pwdmodule.c +++ b/Modules/pwdmodule.c @@ -4,7 +4,9 @@ #include "Python.h" #include "posixmodule.h" -#include +#include // getpwuid() +#include // sysconf() + #include "clinic/pwdmodule.c.h" /*[clinic input] diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c index 4987cf0f2065c2d..367d31f265750e8 100644 --- a/Modules/selectmodule.c +++ b/Modules/selectmodule.c @@ -17,6 +17,7 @@ #include "pycore_time.h" // _PyTime_t #include // offsetof() +#include // close() #ifdef HAVE_SYS_DEVPOLL_H #include