Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to build on Python 3.13: _PyLong_AsByteArray is a private API #156

Open
stefanor opened this issue Sep 13, 2024 · 2 comments
Open

Comments

@stefanor
Copy link

https://docs.python.org/3.13/whatsnew/3.13.html#removed-c-apis
python/cpython#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
@behdad
Copy link
Contributor

behdad commented Sep 13, 2024

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.

@Xmader
Copy link

Xmader commented Sep 27, 2024

The new PyLong_AsNativeBytes API would be a good replacement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants