8000 gh-112026: Add again <unistd.h> include in Python.h · vstinner/cpython@ae65f64 · GitHub
[go: up one dir, main page]

Skip to content

Commit ae65f64

Browse files
committed
pythongh-112026: Add again <unistd.h> include in Python.h
Add again <ctype.h> and <unistd.h> includes in Python.h, but don't include them in the limited C API version 3.13 and newer.
1 parent babb787 commit ae65f64

File tree

2 files changed

+9
-20
lines changed

2 files changed

+9
-20
lines changed

Doc/whatsnew/3.13.rst

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,17 +1178,6 @@ Porting to Python 3.13
11781178
also the ``HAVE_IEEEFP_H`` macro.
11791179
(Contributed by Victor Stinner in :gh:`108765`.)
11801180

1181-
* ``Python.h`` no longer includes the ``<unistd.h>`` standard header file. If
1182-
needed, it should now be included explicitly. For example, it provides the
1183-
functions: ``read()``, ``write()``, ``close()``, ``isatty()``, ``lseek()``,
1184-
``getpid()``, ``getcwd()``, ``sysconf()``, ``getpagesize()``, ``alarm()`` and
1185-
``pause()``.
1186-
As a consequence, ``_POSIX_SEMAPHORES`` and ``_POSIX_THREADS`` macros are no
1187-
longer defined by ``Python.h``. The ``HAVE_UNISTD_H`` and ``HAVE_PTHREAD_H``
1188-
macros defined by ``Python.h`` can be used to decide if ``<unistd.h>`` and
1189-
``<pthread.h>`` header files can be included.
1190-
(Contributed by Victor Stinner in :gh:`108765`.)
1191-
11921181
* ``Python.h`` no longer includes these standard header files: ``<time.h>``,
11931182
``<sys/select.h>`` and ``<sys/time.h>``. If needed, they should now be
11941183
included explicitly. For example, ``<time.h>`` provides the ``clock()`` and
@@ -1197,13 +1186,6 @@ Porting to Python 3.13
11971186
and ``setitimer()`` functions.
11981187
(Contributed by Victor Stinner in :gh:`108765`.)
11991188

1200-
* ``Python.h`` no longer includes the ``<ctype.h>`` standard header file. If
1201-
needed, it should now be included explicitly. For example, it provides
1202-
``isalpha()`` and ``tolower()`` functions which are locale dependent. Python
1203-
provides locale independent functions, like :c:func:`!Py_ISALPHA` and
1204-
:c:func:`!Py_TOLOWER`.
1205-
(Contributed by Victor Stinner in :gh:`108765`.)
1206-
12071189
* If the :c:macro:`Py_LIMITED_API` macro is defined, :c:macro:`!Py_BUILD_CORE`,
12081190
:c:macro:`!Py_BUILD_CORE_BUILTIN` and :c:macro:`!Py_BUILD_CORE_MODULE` macros
12091191
are now undefined by ``<Python.h>``.

Include/Python.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,22 @@
2626
# include <sys/types.h> // ssize_t
2727
#endif
2828

29-
// errno.h, stdio.h, stdlib.h and string.h headers are no longer used by
30-
// Python, but kept for backward compatibility (avoid compiler warnings).
29+
// <errno.h>, <stdio.h>, <stdlib.h> and <string.h> headers are no longer used
30+
// by Python, but kept for backward compatibility of third party C extensions.
3131
// They are no longer included by limited C API version 3.11 and newer.
32+
//
33+
// The <ctype.h> and <unistd.h> headers are no longer included by limited C API
34+
// version 3.13 and newer.
3235
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
3336
# include <errno.h> // errno
3437
# include <stdio.h> // FILE*
3538
# include <stdlib.h> // getenv()
3639
# include <string.h> // memcpy()
3740
#endif
41+
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030d0000
42+
# include <ctype.h> // tolower()
43+
# include <unistd.h> // close()
44+
#endif
3845

3946

4047
// Include Python header files

0 commit comments

Comments
 (0)
0