Blob Blame History Raw
From 185ed2dca9d7235402c2fb1ceba77777a1060cef Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
Date: Tue, 31 Oct 2023 12:54:51 +0100
Subject: [PATCH] Add missing <unistd.h> includes for Python 3.13+
 compatibility

According to https://docs.python.org/3.13/whatsnew/3.13.html:

> Python.h no longer includes the <unistd.h> 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() and getpagesize().
> (Contributed by Victor Stinner in
> https://github.com/python/cpython/issues/108765)

The build failures with -Werror=implicit-function-declaration were:

    .../dbus_bindings/unixfd.c: In function 'UnixFd_tp_new':
    .../dbus_bindings/unixfd.c:146:10: error: implicit declaration of function 'dup' [-Werror=implicit-function-declaration]
      146 |     fd = dup(fd_original);
          |          ^~~
    .../dbus_bindings/unixfd.c:146:10: warning: nested extern declaration of 'dup' [-Wnested-externs]
    .../dbus_bindings/unixfd.c:154:9: error: implicit declaration of function 'close'; did you mean 'clone'? [-Werror=implicit-function-declaration]
      154 |         close(fd);
          |         ^~~~~
          |         clone
---
 dbus_bindings/message-get-args.c | 2 ++
 dbus_bindings/unixfd.c           | 1 +
 2 files changed, 3 insertions(+)

diff --git a/dbus_bindings/message-get-args.c b/dbus_bindings/message-get-args.c
index 628a616..f6630b5 100644
--- a/dbus_bindings/message-get-args.c
+++ b/dbus_bindings/message-get-args.c
@@ -26,6 +26,8 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
+#include <unistd.h>
+
 #include "dbus_bindings-internal.h"
 
 #define DBG_IS_TOO_VERBOSE
diff --git a/dbus_bindings/unixfd.c b/dbus_bindings/unixfd.c
index e515cd3..68399b0 100644
--- a/dbus_bindings/unixfd.c
+++ b/dbus_bindings/unixfd.c
@@ -30,6 +30,7 @@
 
 #include <Python.h>
 #include <structmember.h>
+#include <unistd.h>
 
 #include "types-internal.h"
 
-- 
GitLab