Skip to content

Commit 6aede60

Browse files
committed
pythongh-108765: Python.h no longer includes <unistd.h>
1 parent 1b43dc1 commit 6aede60

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

Include/Python.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,13 @@
2626
#ifdef HAVE_STDDEF_H
2727
# include <stddef.h> // size_t
2828
#endif
29-
#ifndef MS_WINDOWS
30-
# include <unistd.h> // sysconf()
29+
#ifdef HAVE_SYS_TYPES_H
30+
# include <sys/types.h> // ssize_t
3131
#endif
3232

33-
// errno.h, stdio.h, stdlib.h and string.h headers are no longer used by Python
34-
// headers, but kept for backward compatibility (no introduce new compiler
35-
// warnings). They are not included by the limited C API version 3.11 and
36-
// above.
33+
// errno.h, stdio.h, stdlib.h and string.h headers are no longer used by
34+
// Python, but kept for backward compatibility (avoid compiler warnings).
35+
// They are no longer included by limited C API version 3.11 and newer.
3736
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
3837
# include <errno.h> // errno
3938
# include <stdio.h> // FILE*

Modules/grpmodule.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
#include "Python.h"
55
#include "posixmodule.h"
66

7-
#include <grp.h>
7+
#include <grp.h> // getgrgid_r()
8+
#include <unistd.h> // sysconf()
89

910
#include "clinic/grpmodule.c.h"
1011
/*[clinic input]

Modules/mmapmodule.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "pycore_fileutils.h" // _Py_stat_struct
2929

3030
#include <stddef.h> // offsetof()
31+
#include <unistd.h> // close()
3132

3233
// to support MS_WINDOWS_SYSTEM OpenFileMappingA / CreateFileMappingA
3334
// need to be replaced with OpenFileMappingW / CreateFileMappingW

Modules/pwdmodule.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
#include "Python.h"
55
#include "posixmodule.h"
66

7-
#include <pwd.h>
7+
#include <pwd.h> // getpwuid()
8+
#include <unistd.h> // sysconf()
9+
810

911
#include "clinic/pwdmodule.c.h"
1012
/*[clinic input]

Modules/selectmodule.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "pycore_time.h" // _PyTime_t
1818

1919
#include <stddef.h> // offsetof()
20+
#include <unistd.h> // close()
2021

2122
#ifdef HAVE_SYS_DEVPOLL_H
2223
#include <sys/resource.h>

0 commit comments

Comments
 (0)