#1145457 libselinux: FTBFS: selinuxswig_python_wrap.c:6646:34: error: implicit declaration of function 'PyString_FromString'; did you mean 'PyLong_FromString'? [-Wimplicit-function-declaration]

Package:
src:libselinux
Source:
src:libselinux
Submitter:
Santiago Vila
Date:
2026-09-19 20:09:01 UTC
Severity:
normal
Tags:
#1145457#5
Date:
2026-08-25 10:15:32 UTC
From:
To:
Dear maintainer:

During a rebuild of all packages in unstable, this package failed to build.

Below you will find the last part of the build log (probably the most
relevant part, but not necessarily). If required, the full build log
is available here:

https://people.debian.org/~sanvila/build-logs/202608/

About the archive rebuild: The build was made on virtual machines from AWS,
using sbuild and a reduced chroot with only build-essential packages.

If you cannot reproduce the bug please contact me privately, as I
am willing to provide ssh access to a virtual machine where the bug is
fully reproducible.

If this is really a bug in one of the build-depends, please use
reassign and add an affects on src:libselinux, so that this is still
visible in the BTS web page for this package.

Thanks.
--------------------------------------------------------------------------------
[...]
selinuxswig.i:18: Warning 127: %typedef directive is deprecated, use plain typedef instead
selinuxswig.i:19: Warning 127: %typedef directive is deprecated, use plain typedef instead
../include/selinux/avc.h:422: Warning 302: Redefinition of identifier 'avc_cache_stats' as avc_cache_stats(struct avc_cache_stats *) ignored,
../include/selinux/avc.h:402: Warning 302: previous definition of 'avc_cache_stats'.
../include/selinux/selinux.h:154: Warning 451: Setting a const char * variable may leak memory.
../include/selinux/selinux.h:376: Warning 451: Setting a const char * variable may leak memory.
creating build/temp.linux-x86_64-cpython-313
x86_64-linux-gnu-gcc -Wdate-time -D_FORTIFY_SOURCE=2 -D_LARGEFILE64_SOURCE -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/<<PKGBUILDDIR>>=. -flto=auto -ffat-lto-objects -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -fno-semantic-interposition -Wall -Wextra -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I../include -D_GNU_SOURCE -DNO_ANDROID_BACKEND -DUSE_PCRE2 -DPCRE2_CODE_UNIT_WIDTH=8 -DHAVE_STRLCPY -DHAVE_REALLOCARRAY -Wno-error -Wno-deprecated-declarations -Wno-missing-prototypes -Wno-missing-declarations -fPIC -Wdate-time -D_FORTIFY_SOURCE=2 -D_LARGEFILE64_SOURCE -fPIC -I../include -I/usr/include/python3.13 -c selinuxswig_python_wrap.c -o build/temp.linux-x86_64-cpython-313/selinuxswig_python_wrap.o
selinuxswig_python_wrap.c: In function ‘_wrap_get_ordered_context_list’:
selinuxswig_python_wrap.c:6646:34: error: implicit declaration of function ‘PyString_FromString’; did you mean ‘PyLong_FromString’? [-Wimplicit-function-declaration]
 6646 |         PyList_SetItem(plist, i, PyString_FromString((*arg3)[i]));
      |                                  ^~~~~~~~~~~~~~~~~~~
      |                                  PyLong_FromString
selinuxswig_python_wrap.c:6646:34: error: passing argument 3 of ‘PyList_SetItem’ makes pointer from integer without a cast [-Wint-conversion]
 6646 |         PyList_SetItem(plist, i, PyString_FromString((*arg3)[i]));
      |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                  |
      |                                  int
In file included from /usr/include/python3.13/Python.h:90,
                 from selinuxswig_python_wrap.c:206:
/usr/include/python3.13/listobject.h:35:56: note: expected ‘PyObject *’ {aka ‘struct _object *’} but argument is of type ‘int’
   35 | PyAPI_FUNC(int) PyList_SetItem(PyObject *, Py_ssize_t, PyObject *);
      |                                                        ^~~~~~~~~~
selinuxswig_python_wrap.c: In function ‘_wrap_get_ordered_context_list_with_level’:
selinuxswig_python_wrap.c:6724:34: error: passing argument 3 of ‘PyList_SetItem’ makes pointer from integer without a cast [-Wint-conversion]
 6724 |         PyList_SetItem(plist, i, PyString_FromString((*arg4)[i]));
      |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                  |
      |                                  int
/usr/include/python3.13/listobject.h:35:56: note: expected ‘PyObject *’ {aka ‘struct _object *’} but argument is of type ‘int’
   35 | PyAPI_FUNC(int) PyList_SetItem(PyObject *, Py_ssize_t, PyObject *);
      |                                                        ^~~~~~~~~~
selinuxswig_python_wrap.c: In function ‘_wrap_security_compute_user’:
selinuxswig_python_wrap.c:11512:34: error: passing argument 3 of ‘PyList_SetItem’ makes pointer from integer without a cast [-Wint-conversion]
11512 |         PyList_SetItem(plist, i, PyString_FromString((*arg3)[i]));
      |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                  |
      |                                  int
/usr/include/python3.13/listobject.h:35:56: note: expected ‘PyObject *’ {aka ‘struct _object *’} but argument is of type ‘int’
   35 | PyAPI_FUNC(int) PyList_SetItem(PyObject *, Py_ssize_t, PyObject *);
      |                                                        ^~~~~~~~~~
selinuxswig_python_wrap.c: In function ‘_wrap_security_compute_user_raw’:
selinuxswig_python_wrap.c:11583:34: error: passing argument 3 of ‘PyList_SetItem’ makes pointer from integer without a cast [-Wint-conversion]
11583 |         PyList_SetItem(plist, i, PyString_FromString((*arg3)[i]));
      |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                  |
      |                                  int
/usr/include/python3.13/listobject.h:35:56: note: expected ‘PyObject *’ {aka ‘struct _object *’} but argument is of type ‘int’
   35 | PyAPI_FUNC(int) PyList_SetItem(PyObject *, Py_ssize_t, PyObject *);
      |                                                        ^~~~~~~~~~
selinuxswig_python_wrap.c: In function ‘_wrap_security_get_boolean_names’:
selinuxswig_python_wrap.c:12487:31: error: passing argument 3 of ‘PyList_SetItem’ makes pointer from integer without a cast [-Wint-conversion]
12487 |       PyList_SetItem(list, i, PyString_FromString((*arg1)[i]));
      |                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                               |
      |                               int
/usr/include/python3.13/listobject.h:35:56: note: expected ‘PyObject *’ {aka ‘struct _object *’} but argument is of type ‘int’
   35 | PyAPI_FUNC(int) PyList_SetItem(PyObject *, Py_ssize_t, PyObject *);
      |                                                        ^~~~~~~~~~
error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1

TIP pass --env-dir and --sdist-extract-dir to keep the build environment and sources, then see https://build.pypa.io/en/stable/how-to/troubleshooting.html#debug-a-failed-build for help debugging a failed build
ERROR Backend subprocess exited when trying to invoke build_wheel
make[3]: *** [Makefile:154: pywrap] Error 1
make[3]: Leaving directory '/<<PKGBUILDDIR>>/src'
make[2]: *** [Makefile:62: pywrap] Error 2
make[2]: Leaving directory '/<<PKGBUILDDIR>>'
make[1]: *** [debian/rules:49: build-python-3.13] Error 2
make[1]: Leaving directory '/<<PKGBUILDDIR>>'
make: *** [debian/rules:37: binary] Error 2
dpkg-buildpackage: error: debian/rules binary subprocess failed with exit status 2
--------------------------------------------------------------------------------

#1145457#10
Date:
2026-08-29 16:29:30 UTC
From:
To:
Hi,

The current bug is caused by 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.

I have submitted a patch to fix the issue as a merge request at Salsa. [2]

The issue appears to have been fixed upstream (commit fb518ff4 [3]), with
further explanations given issue #538 [4]. However, the associated patch
[5] does not apply cleanly against version 3.11-2 of the Debian package.

Best,5A

Rafael Laboissière

[1] https://github.com/swig/swig/commit/79f7a2b7cb7ddc256eba09c8770133148025171d
[2] https://salsa.debian.org/selinux-team/libselinux/-/merge_requests/15/commits
[3] https://github.com/SELinuxProject/selinux/commit/fb518ff492cd6a286f35b415cbd7fd0f6e3faedb
[4] https://github.com/SELinuxProject/selinux/issues/538
[5] https://github.com/SELinuxProject/selinux/commit/fb518ff492cd6a286f35b415cbd7fd0f6e3faedb.diff

#1145457#17
Date:
2026-09-19 20:07:38 UTC
From:
To:
user debian-python@lists.debian.org
usertags 1145457 python3.15
tags 1145457 patch
thanks

Hi!

While rebuilding the python related packages against the Python 3.15rc2
version I ran into this FTBFS [1].

Similarly to what Rafael mentioned, I also saw that applying upstream
patch: Replace PyString_FromString with PyUnicode_FromString for SWIG
4.5.0 compatibility (fb518ff492cd6a286f35b415cbd7fd0f6e3faedb) solves
this issue.

I've applied this fix in the sandbox [2] to verify that it builds
successfully, please consider applying it in Debian to get the package
back to a healthy state.

Happy hacking,

[1]: https://debusine.debian.net/debian/r-python-python3.15/artifact/4716983/
[2]: https://debusine.debian.net/debian/r-python-python3.15/