Skip to content

[BUG] py312 compatibility #4788

Closed
Closed
@tacaswell

Description

@tacaswell

Describe the bug
A clear and concise description of what the bug is.

python/cpython#92537 removed the function _PyUnicode_Ready which cython is using.

To Reproduce
Code to reproduce the behaviour:

Attempt to build scipy fails with missing symbols. It looks like this changes was anticipated, however the code is guarded on defined(PyUnicode_IS_READY) and CPyhon retained that function as a no-op for back-compatibility. Checking if the private function is defined fixes this problem (but exposes another that I will open an issue for shortly).

I will open a PR shortly with the diff

$ git diff
diff --git a/Cython/Utility/ModuleSetupCode.c b/Cython/Utility/ModuleSetupCode.c
index f05840161..10b7b887d 100644
--- a/Cython/Utility/ModuleSetupCode.c
+++ b/Cython/Utility/ModuleSetupCode.c
@@ -928,7 +928,7 @@ static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStrWithError(PyObject *dict,
   /* new Py3.3 unicode type (PEP 393) */
   #define CYTHON_PEP393_ENABLED 1
 
-  #if defined(PyUnicode_IS_READY)
+  #if defined(_PyUnicode_Ready)
   #define __Pyx_PyUnicode_READY(op)       (likely(PyUnicode_IS_READY(op)) ? \
                                               0 : _PyUnicode_Ready((PyObject *)(op)))
   #else
@@ -943,7 +943,7 @@ static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStrWithError(PyObject *dict,
   #define __Pyx_PyUnicode_DATA(u)         PyUnicode_DATA(u)
   #define __Pyx_PyUnicode_READ(k, d, i)   PyUnicode_READ(k, d, i)
   #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  PyUnicode_WRITE(k, d, i, ch)
-  #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE)
+  #if defined(_PyUnicode_Ready) && defined(PyUnicode_GET_SIZE)
   #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03090000
   // Avoid calling deprecated C-API functions in Py3.9+ that PEP-623 schedules for removal in Py3.12.
   // https://www.python.org/dev/peps/pep-0623/

Expected behavior
A clear and concise description of what you expected to happen.

Environment (please complete the following information):

  • OS: [e.g. Linux, Windows, macOS] Linux
  • Python version [e.g. 3.8.4] current main (py312)
  • Cython version [e.g. 0.29.18] current master

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions