contrib/distcc/python-3.9.patch

56 lines
1.8 KiB
Diff

From 83e030a852daf1d4d8c906e46f86375d421b781e Mon Sep 17 00:00:00 2001
From: hephooey <hephooey@users.noreply.github.com>
Date: Sun, 15 Jan 2023 15:43:50 -0500
Subject: [PATCH] Replace int with Py_ssize_t for distcc pump extension
Defining PY_SSIZE_T_CLEAN is required since python 3.10, and I have to
modify the type of length to match it. Otherwise functions like
OsPathExists will always return False.
The PY_SSIZE_T_CLEAN macro is supported at least back to python 3.5
according to docs.python.org, that is why I included it without any
python version conditions
---
.../c_extensions/distcc_pump_c_extensions_module.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/include_server/c_extensions/distcc_pump_c_extensions_module.c b/include_server/c_extensions/distcc_pump_c_extensions_module.c
index 763dd425..a4c6e9eb 100644
--- a/include_server/c_extensions/distcc_pump_c_extensions_module.c
+++ b/include_server/c_extensions/distcc_pump_c_extensions_module.c
@@ -21,6 +21,7 @@
/* distcc_pump_c_extensions_module.c -- Python bindings for distcc-pump
* extensions */
+#define PY_SSIZE_T_CLEAN
#include "Python.h"
static const char *version = ".01";
@@ -56,7 +57,7 @@ static PyObject *
CompressLzo1xAlloc(PyObject *dummy, PyObject *args) {
PyObject *string_object;
const char *in_buf;
- int in_len;
+ Py_ssize_t in_len;
char *out_buf;
size_t out_len;
UNUSED(dummy);
@@ -241,7 +242,7 @@ static /* const */ char OsPathExists_doc__[] =
static PyObject *
OsPathExists(PyObject *dummy, PyObject *args) {
const char *in;
- int len;
+ Py_ssize_t len;
int res;
struct stat buf;
@@ -275,7 +276,7 @@ static /* const */ char OsPathIsFile_doc__[] =
static PyObject *
OsPathIsFile(PyObject *dummy, PyObject *args) {
const char *in;
- int len;
+ Py_ssize_t len;
int res;
struct stat buf;