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

Preliminary support for Python 3.13a5 #83

Merged
merged 4 commits into from
Apr 9, 2024

Conversation

icemac
Copy link
Member

@icemac icemac commented Mar 8, 2024

Again we get errors while compiling the C code:

gcc -pthread -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall -O3 -pipe -fPIC -I/opt/hostedtoolcache/Python/3.13.0-alpha.4/x64/include/python3.13 -c src/zodbpickle/_pickle_33.c -o build/temp.linux-x86_64-cpython-313/src/zodbpickle/_pickle_33.o
src/zodbpickle/_pickle_[33](https://github.com/zopefoundation/zodbpickle/actions/runs/8200508876/job/22427408652?pr=83#step:10:34).c: In function ‘save_long’:
src/zodbpickle/_pickle_33.c:1668:13: error: too few arguments to function ‘_PyLong_AsByteArray’
 1668 |         i = _PyLong_AsByteArray((PyLongObject *)obj,
      |             ^~~~~~~~~~~~~~~~~~~
In file included from /opt/hostedtoolcache/Python/3.13.0-alpha.4/x64/include/python3.13/longobject.h:90,
                 from /opt/hostedtoolcache/Python/3.13.0-alpha.4/x64/include/python3.13/Python.h:66,
                 from src/zodbpickle/_pickle_33.c:1:
/opt/hostedtoolcache/Python/3.13.0-alpha.4/x64/include/python3.13/cpython/longobject.h:85:17: note: declared here
   85 | PyAPI_FUNC(int) _PyLong_AsByteArray(PyLongObject* v,
      |                 ^~~~~~~~~~~~~~~~~~~
src/zodbpickle/_pickle_33.c: In function ‘save_float’:
src/zodbpickle/_pickle_33.c:17[40](https://github.com/zopefoundation/zodbpickle/actions/runs/8200508876/job/22427408652?pr=83#step:10:41):30: warning: pointer targets in passing argument 2 of ‘PyFloat_Pack8’ differ in signedness [-Wpointer-sign]
 1740 |         if (PyFloat_Pack8(x, (unsigned char *)&pdata[1], 0) < 0)
      |                              ^~~~~~~~~~~~~~~~~~~~~~~~~~
      |                              |
      |                              unsigned char *
In file included from /opt/hostedtoolcache/Python/3.13.0-alpha.4/x64/include/python3.13/floatobject.h:47,
                 from /opt/hostedtoolcache/Python/3.13.0-alpha.4/x64/include/python3.13/Python.h:69,
                 from src/zodbpickle/_pickle_33.c:1:
/opt/hostedtoolcache/Python/3.13.0-alpha.4/x64/include/python3.13/cpython/floatobject.h:23:47: note: expected ‘char *’ but argument is of type ‘unsigned char *’
   23 | PyAPI_FUNC(int) PyFloat_Pack8(double x, char *p, int le);
      |                                         ~~~~~~^
src/zodbpickle/_pickle_33.c: In function ‘load_binfloat’:
src/zodbpickle/_pickle_33.c:[42](https://github.com/zopefoundation/zodbpickle/actions/runs/8200508876/job/22427408652?pr=83#step:10:43)92:25: warning: pointer targets in passing argument 1 of ‘PyFloat_Unpack8’ differ in signedness [-Wpointer-sign]
 4292 |     x = PyFloat_Unpack8((unsigned char *)s, 0);
      |                         ^~~~~~~~~~~~~~~~~~
      |                         |
      |                         unsigned char *
In file included from /opt/hostedtoolcache/Python/3.13.0-alpha.4/x64/include/python3.13/floatobject.h:[47](https://github.com/zopefoundation/zodbpickle/actions/runs/8200508876/job/22427408652?pr=83#step:10:48),
                 from /opt/hostedtoolcache/Python/3.13.0-alpha.4/x64/include/python3.13/Python.h:69,
                 from src/zodbpickle/_pickle_33.c:1:
/opt/hostedtoolcache/Python/3.13.0-alpha.4/x64/include/python3.13/cpython/floatobject.h:27:[48](https://github.com/zopefoundation/zodbpickle/actions/runs/8200508876/job/22427408652?pr=83#step:10:49): note: expected ‘const char *’ but argument is of type ‘unsigned char *’
   27 | PyAPI_FUNC(double) PyFloat_Unpack8(const char *p, int le);
      |                                    ~~~~~~~~~~~~^
error: command '/usr/bin/gcc' failed with exit code 1

@icemac icemac self-assigned this Mar 8, 2024
@icemac icemac changed the title Preliminary support for Python 3.13a3 Preliminary support for Python 3.13a5 Mar 14, 2024
@icemac
Copy link
Member Author

icemac commented Mar 14, 2024

@davisagli Could you please have a look at the new build failures as we are now running on Python 3.13a4+?

@davisagli
Copy link
Member

@icemac It looks like the _PyLong_AsByteArray function signature was modified, and there is some ongoing discussion about a public API to replace it in python/cpython#111140

I'll try to take a closer look in the next week at whether we can do something simple to work around it.

@tseaver
Copy link
Member

tseaver commented Apr 3, 2024

I can reproduce the _PyLong_AsByteArrayerror locally with Python 3.13.0a5. I'll try to look at this one this week.

Work around added 'with_exceptions' argument to '_PyLong_AsBytesArray',
added in python/cpython@7861dfd.
@tseaver
Copy link
Member

tseaver commented Apr 5, 2024

The error against 3.13.0a5 looks like so:

$ gcc -pthread -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall -fPIC -I.tox/.pkg-cpython313/include -I/opt/Python-3.13.0a5/include/python3.13 -c src/zodbpickle/_pickle_33.c -o /tmp/_pickle_33.o
src/zodbpickle/_pickle_33.c: In function ‘save_long’:
src/zodbpickle/_pickle_33.c:1668:13: error: too few arguments to function ‘_PyLong_AsByteArray’
 1668 |         i = _PyLong_AsByteArray((PyLongObject *)obj,
      |             ^~~~~~~~~~~~~~~~~~~
In file included from /opt/Python-3.13.0a5/include/python3.13/longobject.h:90,
                 from /opt/Python-3.13.0a5/include/python3.13/Python.h:66,
                 from src/zodbpickle/_pickle_33.c:1:
/opt/Python-3.13.0a5/include/python3.13/cpython/longobject.h:85:17: note: declared here
   85 | PyAPI_FUNC(int) _PyLong_AsByteArray(PyLongObject* v,
      |                 ^~~~~~~~~~~~~~~~~~~
src/zodbpickle/_pickle_33.c: In function ‘save_float’:
src/zodbpickle/_pickle_33.c:1740:30: warning: pointer targets in passing argument 2 of ‘PyFloat_Pack8’ differ in signedness [-Wpointer-sign]
 1740 |         if (PyFloat_Pack8(x, (unsigned char *)&pdata[1], 0) < 0)
      |                              ^~~~~~~~~~~~~~~~~~~~~~~~~~
      |                              |
      |                              unsigned char *
In file included from /opt/Python-3.13.0a5/include/python3.13/floatobject.h:47,
                 from /opt/Python-3.13.0a5/include/python3.13/Python.h:69,
                 from src/zodbpickle/_pickle_33.c:1:
/opt/Python-3.13.0a5/include/python3.13/cpython/floatobject.h:23:47: note: expected ‘char *’ but argument is of type ‘unsigned char *
   23 | PyAPI_FUNC(int) PyFloat_Pack8(double x, char *p, int le);
      |                                         ~~~~~~^
src/zodbpickle/_pickle_33.c: In function ‘load_binfloat’:
src/zodbpickle/_pickle_33.c:4292:25: warning: pointer targets in passing argument 1 of ‘PyFloat_Unpack8’ differ in signedness [-Wpointer-sign]
 4292 |     x = PyFloat_Unpack8((unsigned char *)s, 0);
      |                         ^~~~~~~~~~~~~~~~~~
      |                         |
      |                         unsigned char *
In file included from /opt/Python-3.13.0a5/include/python3.13/floatobject.h:47,
                 from /opt/Python-3.13.0a5/include/python3.13/Python.h:69,
                 from src/zodbpickle/_pickle_33.c:1:
/opt/Python-3.13.0a5/include/python3.13/cpython/floatobject.h:27:48: note: expected ‘const char *’ but argument is of type ‘unsigned char *
   27 | PyAPI_FUNC(double) PyFloat_Unpack8(const char *p, int le);

A quick spelunk through the versions of Python's _pickle.cI have on my system:

$ for pyver in $(ls -d /opt/src/Python-3* | cut -d "-" -f 2 | cut -d "." -f 2,3 | sort -g); do
>       mod="/opt/src/Python-3.$pyver/Modules/_pickle.c"
>       echo "---------------------------------------------"
>       echo $mod
>       echo "---------------------------------------------"
>       grep -A3 _PyLong_AsByteArray $mod
>  done
---------------------------------------------
/opt/src/Python-3.5.9/Modules/_pickle.c
---------------------------------------------
        i = _PyLong_AsByteArray((PyLongObject *)obj,
                                pdata, nbytes,
                                1 /* little endian */ , 1 /* signed */ );
        if (i < 0)
---------------------------------------------
/opt/src/Python-3.6.15/Modules/_pickle.c
---------------------------------------------
        i = _PyLong_AsByteArray((PyLongObject *)obj,
                                pdata, nbytes,
                                1 /* little endian */ , 1 /* signed */ );
        if (i < 0)
---------------------------------------------
/opt/src/Python-3.7.12/Modules/_pickle.c
---------------------------------------------
        i = _PyLong_AsByteArray((PyLongObject *)obj,
                                pdata, nbytes,
                                1 /* little endian */ , 1 /* signed */ );
        if (i < 0)
---------------------------------------------
/opt/src/Python-3.8.12/Modules/_pickle.c
---------------------------------------------
        i = _PyLong_AsByteArray((PyLongObject *)obj,
                                pdata, nbytes,
                                1 /* little endian */ , 1 /* signed */ );
        if (i < 0)
---------------------------------------------
/opt/src/Python-3.8.19/Modules/_pickle.c
---------------------------------------------
        i = _PyLong_AsByteArray((PyLongObject *)obj,
                                pdata, nbytes,
                                1 /* little endian */ , 1 /* signed */ );
        if (i < 0)
---------------------------------------------
/opt/src/Python-3.9.19/Modules/_pickle.c
---------------------------------------------
        i = _PyLong_AsByteArray((PyLongObject *)obj,
                                pdata, nbytes,
                                1 /* little endian */ , 1 /* signed */ );
        if (i < 0)
---------------------------------------------
/opt/src/Python-3.9.7/Modules/_pickle.c
---------------------------------------------
        i = _PyLong_AsByteArray((PyLongObject *)obj,
                                pdata, nbytes,
                                1 /* little endian */ , 1 /* signed */ );
        if (i < 0)
---------------------------------------------
/opt/src/Python-3.10.0/Modules/_pickle.c
---------------------------------------------
        i = _PyLong_AsByteArray((PyLongObject *)obj,
                                pdata, nbytes,
                                1 /* little endian */ , 1 /* signed */ );
        if (i < 0)
---------------------------------------------
/opt/src/Python-3.10.14/Modules/_pickle.c
---------------------------------------------
        i = _PyLong_AsByteArray((PyLongObject *)obj,
                                pdata, nbytes,
                                1 /* little endian */ , 1 /* signed */ );
        if (i < 0)
---------------------------------------------
/opt/src/Python-3.11.1/Modules/_pickle.c
---------------------------------------------
        i = _PyLong_AsByteArray((PyLongObject *)obj,
                                pdata, nbytes,
                                1 /* little endian */ , 1 /* signed */ );
        if (i < 0)
---------------------------------------------
/opt/src/Python-3.11.7/Modules/_pickle.c
---------------------------------------------
        i = _PyLong_AsByteArray((PyLongObject *)obj,
                                pdata, nbytes,
                                1 /* little endian */ , 1 /* signed */ );
        if (i < 0)
---------------------------------------------
/opt/src/Python-3.11.8/Modules/_pickle.c
---------------------------------------------
        i = _PyLong_AsByteArray((PyLongObject *)obj,
                                pdata, nbytes,
                                1 /* little endian */ , 1 /* signed */ );
        if (i < 0)
---------------------------------------------
/opt/src/Python-3.12.0/Modules/_pickle.c
---------------------------------------------
        i = _PyLong_AsByteArray((PyLongObject *)obj,
                                pdata, nbytes,
                                1 /* little endian */ , 1 /* signed */ );
        if (i < 0)
---------------------------------------------
/opt/src/Python-3.12.1/Modules/_pickle.c
---------------------------------------------
        i = _PyLong_AsByteArray((PyLongObject *)obj,
                                pdata, nbytes,
                                1 /* little endian */ , 1 /* signed */ );
        if (i < 0)
---------------------------------------------
/opt/src/Python-3.12.2/Modules/_pickle.c
---------------------------------------------
        i = _PyLong_AsByteArray((PyLongObject *)obj,
                                pdata, nbytes,
                                1 /* little endian */ , 1 /* signed */ );
        if (i < 0)
---------------------------------------------
/opt/src/Python-3.13.0a5/Modules/_pickle.c
---------------------------------------------
#include "pycore_long.h"          // _PyLong_AsByteArray()
#include "pycore_moduleobject.h"  // _PyModule_GetState()
#include "pycore_object.h"        // _PyNone_Type
#include "pycore_pystate.h"       // _PyThreadState_GET()
--
        i = _PyLong_AsByteArray((PyLongObject *)obj,
                                pdata, nbytes,
                                1 /* little endian */ , 1 /* signed */ ,
                                1 /* with exceptions */);

.github/workflows/tests.yml Show resolved Hide resolved
@icemac icemac merged commit 3dedd37 into master Apr 9, 2024
44 checks passed
@icemac icemac deleted the config-with-c-code-template-1351c95d branch April 9, 2024 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants