| 1 |
From 6c965463223ea46d0b7ae22586cadc150f719f84 Mon Sep 17 00:00:00 2001 |
| 2 |
From: Jitka Plesnikova <[email protected]> |
| 3 |
Date: Tue, 11 Aug 2026 13:55:58 +0200 |
| 4 |
Subject: [PATCH] python: update for SWIG 4.5 |
| 5 |
|
| 6 |
SWIG 4.5.0 removed Python 2 compatibility macros (PyInt_, PyString_, SWIG_Python_str_*) |
| 7 |
from its runtime header pyhead.swg (see commit [1]). These macros mapped old Python 2 |
| 8 |
C API names to their Python 3 equivalents. Packages that reference them in custom SWIG |
| 9 |
typemaps or pre-generated wrapper code now fail to compile. |
| 10 |
|
| 11 |
This patch replaces all occurrences with the corresponding Python 3 C API functions. |
| 12 |
The replacements are safe since the macros were already aliased to these exact functions |
| 13 |
in SWIG's Python 3 code path. |
| 14 |
|
| 15 |
[1] https://github.com/swig/swig/commit/79f7a2b7cb7ddc256eba09c8770133148025171d |
| 16 |
--- |
| 17 |
python/ftdi1.i | 4 ++-- |
| 18 |
1 file changed, 2 insertions(+), 2 deletions(-) |
| 19 |
|
| 20 |
diff --git a/python/ftdi1.i b/python/ftdi1.i |
| 21 |
index fac4d16..31e17c6 100644 |
| 22 |
--- a/python/ftdi1.i |
| 23 |
+++ b/python/ftdi1.i |
| 24 |
@@ -91,7 +91,7 @@ char * str2charp_size(PyObject* pyObj, int * size) |
| 25 |
"read_data(context) -> (return_code, buf)" |
| 26 |
%enddef |
| 27 |
%feature("autodoc", ftdi_read_data_docstring) ftdi_read_data; |
| 28 |
-%typemap(in,numinputs=1) (unsigned char *buf, int size) %{ $2 = PyInt_AsLong($input);$1 = (unsigned char*)malloc($2*sizeof(char)); %} |
| 29 |
+%typemap(in,numinputs=1) (unsigned char *buf, int size) %{ $2 = PyLong_AsLong($input);$1 = (unsigned char*)malloc($2*sizeof(char)); %} |
| 30 |
%typemap(argout,noblock=1) (unsigned char *buf, int size) { |
| 31 |
if(result<0) |
| 32 |
$2=0; |
| 33 |
@@ -136,7 +136,7 @@ char * str2charp_size(PyObject* pyObj, int * size) |
| 34 |
int ftdi_get_eeprom_value(struct ftdi_context *ftdi, enum ftdi_eeprom_value value_name, int* value); |
| 35 |
%clear int* value; |
| 36 |
|
| 37 |
-%typemap(in,numinputs=1) (unsigned char *buf, int size) %{ $2 = PyInt_AsLong($input);$1 = (unsigned char*)malloc($2*sizeof(char)); %} |
| 38 |
+%typemap(in,numinputs=1) (unsigned char *buf, int size) %{ $2 = PyLong_AsLong($input);$1 = (unsigned char*)malloc($2*sizeof(char)); %} |
| 39 |
%typemap(argout,noblock=1) (unsigned char *buf, int size) { |
| 40 |
if(result<0) |
| 41 |
$2=0; |
| 42 |
-- |
| 43 |
2.55.0 |
| 44 |
|