Skip to content

Python 3.13 compatibility #24

New issue

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

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

Already on GitHub? # to your account

Merged
merged 2 commits into from
Dec 1, 2023
Merged

Conversation

nitzmahone
Copy link
Member

fixes #23

  • updates obsolete private API aliases removed in 3.13
  • make unraisable tests less brittle to traceback formatting changes across Python versions

Full test suite passes locally on 3.13.0a1 under Linux x86_64 with these changes.

* assert shape of calls to unraisablehook and sanity check traceback contents instead of (varying)  stderr output from default unraisablehook impl
@alex
Copy link
Contributor

alex commented Oct 18, 2023

First commit LGTM. I didn't review teh 2nd commit closely.

@hroncok
Copy link
Contributor

hroncok commented Oct 24, 2023

With -Werror=implicit-function-declaration and Python 3.13.0a1 I get:

      src/c/_cffi_backend.c: In function ‘_my_PyLong_AsUnsignedLongLong’:
      src/c/_cffi_backend.c:868:17: error: implicit declaration of function ‘_PyLong_Sign’ [-Werror=implicit-function-declaration]
        868 |             if (_PyLong_Sign(ob) < 0)
            |                 ^~~~~~~~~~~~
      src/c/_cffi_backend.c: In function ‘cdata_hash’:
      src/c/_cffi_backend.c:2449:12: error: implicit declaration of function ‘_Py_HashPointer’ [-Werror=implicit-function-declaration]
       2449 |     return _Py_HashPointer(((CDataObject *)v)->c_data);
            |            ^~~~~~~~~~~~~~~
      src/c/_cffi_backend.c: In function ‘b_do_dlopen’:
      src/c/_cffi_backend.c:4532:22: warning: ‘Py_FileSystemDefaultEncoding’ is deprecated [-Wdeprecated-declarations]
       4532 |                      Py_FileSystemDefaultEncoding, &filename_or_null, &flags))
            |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
      In file included from /usr/include/python3.13/Python.h:77,
                       from src/c/_cffi_backend.c:2:
      /usr/include/python3.13/fileobject.h:22:46: note: declared here
         22 | Py_DEPRECATED(3.12) PyAPI_DATA(const char *) Py_FileSystemDefaultEncoding;
            |                                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
      src/c/_cffi_backend.c: In function ‘_my_PyErr_WriteUnraisable’:
      src/c/_cffi_backend.c:6121:9: error: implicit declaration of function ‘_PyErr_WriteUnraisableMsg’; did you mean ‘PyErr_WriteUnraisable’? [-Werror=implicit-function-declaration]
       6121 |         _PyErr_WriteUnraisableMsg(PyText_AS_UTF8(s), NULL);
            |         ^~~~~~~~~~~~~~~~~~~~~~~~~
            |         PyErr_WriteUnraisable
      In file included from src/c/cffi1_module.c:15,
                       from src/c/_cffi_backend.c:7976:
      src/c/ffi_obj.c: In function ‘ffi_getctype’:
      src/c/ffi_obj.c:635:36: error: implicit declaration of function ‘isspace’ [-Werror=implicit-function-declaration]
        635 |     while (replace_with[0] != 0 && isspace(replace_with[0]))
            |                                    ^~~~~~~
      src/c/ffi_obj.c:1:1: note: include ‘<ctype.h>’ or provide a declaration of ‘isspace’
        +++ |+#include <ctype.h>
          1 |

Without -Werror=implicit-function-declaration, the thing builds, but I am unsure if it is built correctly. Running the tests with pytest to check.

@hroncok
Copy link
Contributor

hroncok commented Oct 24, 2023

1951 passed, 89 skipped, 4 xfailed, 367 warnings

@hroncok
Copy link
Contributor

hroncok commented Nov 20, 2023

Testing the update unraisable tests to use sys.unraisablehook together with 49127c6 on the recent Python 3.13 git HEAD.

@hroncok
Copy link
Contributor

hroncok commented Nov 20, 2023

tests passed, trying to build cryptography

@hroncok
Copy link
Contributor

hroncok commented Nov 20, 2023

cryptography build succeeded as well

@mindflayer
Copy link

Could you please release a new version with this fix?
It looks like a blocking issue for being able to add support for Python 3.13, impacting several packages.

@edgarrmondragon
Copy link

Could you please release a new version with this fix?
It looks like a blocking issue for being able to add support for Python 3.13, impacting several packages.

@mindflayer 1.17.0rc1 supports Python 3.13

@mindflayer
Copy link

Thank you @edgarrmondragon for sharing it. Do you happen to know when a stable one will be published?

@edgarrmondragon
Copy link

Thank you @edgarrmondragon for sharing it. Do you happen to know when a stable one will be published?

@mindflayer according to #71 (comment), the final release will be tagged soon after 3.13.0rc1 comes out. So some time after 2024-07-30.

DimitriPapadopoulos added a commit to DimitriPapadopoulos/pycaravel that referenced this pull request Apr 9, 2025
In addition to Python 3.8 (min version)

We cannot support Python 3.13 untill this cffi issue is fixed:
python-cffi/cffi#24
DimitriPapadopoulos added a commit to DimitriPapadopoulos/pycaravel that referenced this pull request Apr 9, 2025
In addition to Python 3.8 (min version)

We cannot support Python 3.13 until this cffi issue is fixed:
python-cffi/cffi#24
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cffi fails to build on Python 3.13
5 participants