zopefoundation / zodbpickle

Fork of Python's pickle module to work with ZODB
Other
17 stars 15 forks source link

Preliminary support for Python 3.13a5 #83

Closed icemac closed 6 months ago

icemac commented 7 months ago

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 commented 7 months ago

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

davisagli commented 7 months ago

@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 https://github.com/python/cpython/issues/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 commented 6 months ago

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

tseaver commented 6 months ago

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 */);