compreffor
compreffor copied to clipboard
Fails to build on Python 3.13: _PyLong_AsByteArray is a private API
https://docs.python.org/3.13/whatsnew/3.13.html#removed-c-apis https://github.com/python/cpython/issues/106320
creating build/temp.linux-aarch64-cpython-313/src/cxx
aarch64-linux-gnu-g++ -g -O2 -ffile-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -mbranch-protection=standard -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.13 -c src/cython/_compreffor.cpp -o build/temp.linux-aarch64-cpython-313/src/cython/_compreffor.o -std=c++0x -pthread -Wextra -Wno-unused -Wno-unused-parameter
src/cython/_compreffor.cpp:1253:72: warning: ‘Py_UNICODE’ is deprecated [-Wdeprecated-declarations]
1253 | static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
| ^
In file included from /usr/include/python3.13/unicodeobject.h:1014,
from /usr/include/python3.13/Python.h:75,
from src/cython/_compreffor.cpp:16:
/usr/include/python3.13/cpython/unicodeobject.h:10:37: note: declared here
10 | Py_DEPRECATED(3.13) typedef wchar_t Py_UNICODE;
| ^~~~~~~~~~
src/cython/_compreffor.cpp: In function ‘size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE*)’:
src/cython/_compreffor.cpp:1255:23: warning: ‘Py_UNICODE’ is deprecated [-Wdeprecated-declarations]
1255 | const Py_UNICODE *u_end = u;
| ^~~~~
/usr/include/python3.13/cpython/unicodeobject.h:10:37: note: declared here
10 | Py_DEPRECATED(3.13) typedef wchar_t Py_UNICODE;
| ^~~~~~~~~~
src/cython/_compreffor.cpp: At global scope:
src/cython/_compreffor.cpp:4763:1: warning: missing initializer for member ‘_typeobject::tp_versions_used’ [-Wmissing-field-initializers]
4763 | };
| ^
src/cython/_compreffor.cpp: In function ‘int __Pyx_PyInt_As_int(PyObject*)’:
src/cython/_compreffor.cpp:5352:42: error: too few arguments to function ‘int _PyLong_AsByteArray(PyLongObject*, unsigned char*, size_t, int, int, int)’
5352 | ret = _PyLong_AsByteArray((PyLongObject *)v,
| ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
5353 | bytes, sizeof(val),
| ~~~~~~~~~~~~~~~~~~~
5354 | is_little, !is_unsigned);
| ~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/python3.13/longobject.h:107,
from /usr/include/python3.13/Python.h:77:
/usr/include/python3.13/cpython/longobject.h:111:17: note: declared here
111 | PyAPI_FUNC(int) _PyLong_AsByteArray(PyLongObject* v,
| ^~~~~~~~~~~~~~~~~~~
src/cython/_compreffor.cpp: In function ‘unsigned int __Pyx_PyInt_As_unsigned_int(PyObject*)’:
src/cython/_compreffor.cpp:5687:42: error: too few arguments to function ‘int _PyLong_AsByteArray(PyLongObject*, unsigned char*, size_t, int, int, int)’
5687 | ret = _PyLong_AsByteArray((PyLongObject *)v,
| ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
5688 | bytes, sizeof(val),
| ~~~~~~~~~~~~~~~~~~~
5689 | is_little, !is_unsigned);
| ~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/python3.13/cpython/longobject.h:111:17: note: declared here
111 | PyAPI_FUNC(int) _PyLong_AsByteArray(PyLongObject* v,
| ^~~~~~~~~~~~~~~~~~~
src/cython/_compreffor.cpp: In function ‘long int __Pyx_PyInt_As_long(PyObject*)’:
src/cython/_compreffor.cpp:6100:42: error: too few arguments to function ‘int _PyLong_AsByteArray(PyLongObject*, unsigned char*, size_t, int, int, int)’
6100 | ret = _PyLong_AsByteArray((PyLongObject *)v,
| ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
6101 | bytes, sizeof(val),
| ~~~~~~~~~~~~~~~~~~~
6102 | is_little, !is_unsigned);
| ~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/python3.13/cpython/longobject.h:111:17: note: declared here
111 | PyAPI_FUNC(int) _PyLong_AsByteArray(PyLongObject* v,
| ^~~~~~~~~~~~~~~~~~~
error: command '/usr/bin/aarch64-linux-gnu-g++' failed with exit code 1
Gemini says:
If you're working with code that uses _PyLong_AsByteArray, you should update it to use _PyLong_Bytes to ensure compatibility with newer Python versions and benefit from the improvements.
The new PyLong_AsNativeBytes API would be a good replacement.