Skip to content

Fix types of PyList_Extend args

The first argument is of type PyObject *, not PyListObject *.

This fixes the following build error:

gcc -pthread -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall -fPIC -Isrc -I/tmp/build-env-1snkep81/include -I/opt/_internal/cpython-3.13.1/include/python3.13 -c src/segmentlist.c -o build/temp.linux-x86_64-cpython-313/src/segmentlist.o
src/segmentlist.c: In function ‘segments_SegmentList_New’:
src/segmentlist.c:268:34: error: passing argument 1 of ‘PyList_Extend’ from incompatible pointer type [-Wincompatible-pointer-types]
  268 |                 if(PyList_Extend(new, sequence)) {
      |                                  ^~~
      |                                  |
      |                                  PyListObject *
In file included from /opt/_internal/cpython-3.13.1/include/python3.13/listobject.h:48,
                 from /opt/_internal/cpython-3.13.1/include/python3.13/Python.h:89,
                 from src/segmentlist.c:29:
/opt/_internal/cpython-3.13.1/include/python3.13/cpython/listobject.h:52:41: note: expected ‘PyObject *’ {aka ‘struct _object *’} but argument is of type ‘PyListObject *’
   52 | PyAPI_FUNC(int) PyList_Extend(PyObject *self, PyObject *iterable);
      |                               ~~~~~~~~~~^~~~
src/segmentlist.c: In function ‘__ior__’:
src/segmentlist.c:822:34: error: passing argument 1 of ‘PyList_Extend’ from incompatible pointer type [-Wincompatible-pointer-types]
  822 |                 if(PyList_Extend((PyListObject *) self, other))
      |                                  ^~~~~~~~~~~~~~~~~~~~~
      |                                  |
      |                                  PyListObject *
/opt/_internal/cpython-3.13.1/include/python3.13/cpython/listobject.h:52:41: note: expected ‘PyObject *’ {aka ‘struct _object *’} but argument is of type ‘PyListObject *’
   52 | PyAPI_FUNC(int) PyList_Extend(PyObject *self, PyObject *iterable);
      |                               ~~~~~~~~~~^~~~
src/segmentlist.c: In function ‘__xor__’:
src/segmentlist.c:993:26: error: passing argument 1 of ‘PyList_Extend’ from incompatible pointer type [-Wincompatible-pointer-types]
  993 |         if(PyList_Extend((PyListObject *) new, other)) {
      |                          ^~~~~~~~~~~~~~~~~~~~
      |                          |
      |                          PyListObject *
/opt/_internal/cpython-3.13.1/include/python3.13/cpython/listobject.h:52:41: note: expected ‘PyObject *’ {aka ‘struct _object *’} but argument is of type ‘PyListObject *’
   52 | PyAPI_FUNC(int) PyList_Extend(PyObject *self, PyObject *iterable);
      |                               ~~~~~~~~~~^~~~
error: command '/opt/rh/gcc-toolset-14/root/usr/bin/gcc' failed with exit code 1

See, for example, https://git.ligo.org/computing/software/igwn-segments/-/jobs/3722761.

Merge request reports

Loading