Control: tags -1 + patch upstream fixed-upstream

Hi,

The current issue is due to the removal of the Python 2 compatibility macros in 
version 4.5.0 of SWIG. [1] According to the SWIG authors, these macros were 
retained in the generated code (pyhead.swg) solely for user typemaps. All 
typemap using these macros are updated to call the Python 3 C API directly. .

Note that the issue has been fixed upstream (commit 0b954729 [2]) and the fix 
was included in version 2.9.0.

Attached to this message is a patch that fixes the FTBFS problem for the 
version currently in unstable, namely 2.7.1-7.1. I would like to contribute it 
via a merge request to the Git repository at Salsa. However, the repository was 
updated to version 2.10.0 ten months ago, yet the new package has not been 
released. Additionally, the repository does not contain the changes for version 
2.7.1-7.1 of the package.

N.B.: I am cc'ing this message to Christoph Berg, who uploaded version 
2.7.1-7.1, and Andreas Tille, who prepared version 2.10.0-1 in Git.

Best,

Rafael

[1] https://github.com/swig/swig/commit/79f7a2b7cb7ddc256eba09c8770133148025171d
[2] 
https://github.com/stevengj/nlopt/commit/0b954729dd8b0f1a227c3e4b7c8fe72d4f92c5ea
Description: Build with swig 4.5.0
 Without this patch, the package FTBFS with swig 4.5.0. This is due to
 the removal of the Python 2 compatibility macros in version 4.5.0. [1]
 According to the SWIG authors, these macros were retained in the
 generated code (pyhead.swg) solely for user typemaps. All typemap
 using these macros are updated to call the Python 3 C API
 directly.
 .
 [1] https://github.com/swig/swig/commit/79f7a2b7cb7ddc256eba09c8770133148025171d
Author: Rafael Laboissière <[email protected]>
Bug-Debian: https:/bugs.debian.org/1145848
Forwarded: not-needed
Last-Update: 2026-08-30
        
--- nlopt-2.7.1.orig/src/swig/numpy.i
+++ nlopt-2.7.1/src/swig/numpy.i
@@ -77,8 +77,8 @@
     if (py_obj == NULL          ) return "C NULL value";
     if (py_obj == Py_None       ) return "Python None" ;
     if (PyCallable_Check(py_obj)) return "callable"    ;
-    if (PyString_Check(  py_obj)) return "string"      ;
-    if (PyInt_Check(     py_obj)) return "int"         ;
+    if (PyBytes_Check(  py_obj)) return "string"      ;
+    if (PyLong_Check(     py_obj)) return "int"         ;
     if (PyFloat_Check(   py_obj)) return "float"       ;
     if (PyDict_Check(    py_obj)) return "dict"        ;
     if (PyList_Check(    py_obj)) return "list"        ;
@@ -1942,7 +1942,7 @@
   (PyObject* array = NULL)
 {
   npy_intp dims[1];
-  if (!PyInt_Check($input))
+  if (!PyLong_Check($input))
   {
     const char* typestring = pytype_string($input);
     PyErr_Format(PyExc_TypeError,
@@ -1950,7 +1950,7 @@
                  typestring);
     SWIG_fail;
   }
-  $2 = (DIM_TYPE) PyInt_AsLong($input);
+  $2 = (DIM_TYPE) PyLong_AsLong($input);
   dims[0] = (npy_intp) $2;
   array = PyArray_SimpleNew(1, dims, DATA_TYPECODE);
   if (!array) SWIG_fail;
@@ -1970,7 +1970,7 @@
   (PyObject* array = NULL)
 {
   npy_intp dims[1];
-  if (!PyInt_Check($input))
+  if (!PyLong_Check($input))
   {
     const char* typestring = pytype_string($input);
     PyErr_Format(PyExc_TypeError,
@@ -1978,7 +1978,7 @@
                  typestring);
     SWIG_fail;
   }
-  $1 = (DIM_TYPE) PyInt_AsLong($input);
+  $1 = (DIM_TYPE) PyLong_AsLong($input);
   dims[0] = (npy_intp) $1;
   array = PyArray_SimpleNew(1, dims, DATA_TYPECODE);
   if (!array) SWIG_fail;

Reply via email to