File: 06_Py_ssize_t.patch

package info (click to toggle)
distcc 3.4%2Breally3.4-13
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 4,740 kB
  • sloc: ansic: 27,888; python: 6,460; sh: 4,330; makefile: 912; perl: 68
file content (53 lines) | stat: -rw-r--r-- 1,688 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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(-)

--- 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;