qchateau/cbitstruct

Add Support For Python 3.13

Closed this issue · 1 comments

Thanks for the great project! CPython 3.13.0 is scheduled for release in 3 days (2024-10-01). Testing cbitstruct with the latest 3.13 release candidate (3.13.0rc2), the project fails to compile. Here's the build output produced by running the latest version of cibuildwheel (2.21.1):

  × Building wheel for cbitstruct (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [24 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build/lib.linux-x86_64-cpython-313/cbitstruct
      copying cbitstruct/__init__.py -> build/lib.linux-x86_64-cpython-313/cbitstruct
      creating build/lib.linux-x86_64-cpython-313/cbitstruct/tests
      copying cbitstruct/tests/test_api.py -> build/lib.linux-x86_64-cpython-313/cbitstruct/tests
      copying cbitstruct/tests/test_bitstruct.py -> build/lib.linux-x86_64-cpython-313/cbitstruct/tests
      copying cbitstruct/tests/test_perf.py -> build/lib.linux-x86_64-cpython-313/cbitstruct/tests
      copying cbitstruct/tests/__init__.py -> build/lib.linux-x86_64-cpython-313/cbitstruct/tests
      copying cbitstruct/tests/test_cornercase.py -> build/lib.linux-x86_64-cpython-313/cbitstruct/tests
      copying cbitstruct/tests/test_against_bitstruct.py -> build/lib.linux-x86_64-cpython-313/cbitstruct/tests
      running build_ext
      building 'cbitstruct._cbitstruct' extension
      creating build/temp.linux-x86_64-cpython-313/cbitstruct
      gcc -pthread -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall -fPIC -Icbitstruct/ -I/opt/_internal/cpython-3.13.0rc2/include/python3.13 -c cbitstruct/_cbitstruct.c -o build/temp.linux-x86_64-cpython-313/cbitstruct/_cbitstruct.o -std=c11 -Wall -Werror -O3
      In file included from cbitstruct/_cbitstruct.c:833:
      cbitstruct/clinic/_cbitstruct.c.37.h: In function ‘CompiledFormat_unpack’:
      cbitstruct/clinic/_cbitstruct.c.37.h:83:10: error: implicit declaration of function ‘_PyArg_ParseStackAndKeywords’; did you mean ‘PyArg_ParseTupleAndKeywords’? [-Werror=implicit-function-declaration]
         83 |     if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
            |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
            |          PyArg_ParseTupleAndKeywords
      cc1: all warnings being treated as errors
      error: command '/opt/rh/devtoolset-10/root/usr/bin/gcc' failed with exit code 1
      [end of output]

The issue is that cbitstruct uses _PyArg_ParseStackAndKeywords(), which is a private Python C API that has been removed in Python 3.13. A now-closed CPython issue discussing this removal can be found here: python/cpython#112136. The gist of the discussion is that the removal won't be reverted and users of the API must find an alternative.

Thanks for raising a PR, I've tagged 1.1.1 with support for py313 !