Bug 2155702

Summary: Cython generates code that uses Python C API functions removed in Python 3.12
Product: [Fedora] Fedora Reporter: Mattias Ellert <mattias.ellert>
Component: CythonAssignee: Tomáš Hrnčiar <thrnciar>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 38CC: igor.raits, mhroncok, ndbecker2, pviktori, python-packagers-sig, steve.traylen
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-02-23 08:29:50 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 2135404, 2154877, 2155427    

Description Mattias Ellert 2022-12-21 23:04:49 UTC
Description of problem:

When trying to address the bugzilla report that lhapdf is not buildable with Python 3.12, I encountered that Cython generates code that uses Python C API functions that have been removed in Python 3.12:

/builddir/build/BUILD/LHAPDF-6.5.3/wrappers/python/lhapdf.cpp: In function ‘int __Pyx_PyUnicode_Equals(PyObject*, PyObject*, int)’:
/builddir/build/BUILD/LHAPDF-6.5.3/wrappers/python/lhapdf.cpp:571:51: error: ‘_PyUnicode_Ready’ was not declared in this scope; did you mean ‘PyUnicode_READY’?
  571 |                                               0 : _PyUnicode_Ready((PyObject *)(op)))
      |                                                   ^~~~~~~~~~~~~~~~
/builddir/build/BUILD/LHAPDF-6.5.3/wrappers/python/lhapdf.cpp:977:43: note: in definition of macro ‘unlikely’
  977 |   #define unlikely(x) __builtin_expect(!!(x), 0)
      |                                           ^
/builddir/build/BUILD/LHAPDF-6.5.3/wrappers/python/lhapdf.cpp:26280:22: note: in expansion of macro ‘__Pyx_PyUnicode_READY’
26280 |         if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
      |                      ^~~~~~~~~~~~~~~~~~~~~
/builddir/build/BUILD/LHAPDF-6.5.3/wrappers/python/lhapdf.cpp: In function ‘const char* __Pyx_PyUnicode_AsStringAndSize(PyObject*, Py_ssize_t*)’:
/builddir/build/BUILD/LHAPDF-6.5.3/wrappers/python/lhapdf.cpp:571:51: error: ‘_PyUnicode_Ready’ was not declared in this scope; did you mean ‘PyUnicode_READY’?
  571 |                                               0 : _PyUnicode_Ready((PyObject *)(op)))
      |                                                   ^~~~~~~~~~~~~~~~
/builddir/build/BUILD/LHAPDF-6.5.3/wrappers/python/lhapdf.cpp:977:43: note: in definition of macro ‘unlikely’
  977 |   #define unlikely(x) __builtin_expect(!!(x), 0)
      |                                           ^
/builddir/build/BUILD/LHAPDF-6.5.3/wrappers/python/lhapdf.cpp:29016:18: note: in expansion of macro ‘__Pyx_PyUnicode_READY’
29016 |     if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
      |                  ^~~~~~~~~~~~~~~~~~~~~


Version-Release number of selected component (if applicable):

DEBUG util.py:445:   python3-Cython                  x86_64 0.29.32-1.fc38     \
     python312 2.5 M


How reproducible:

Always


Actual results:

Generated code calls functions removed in Python 3.12


Expected results:

Generated code compiles with Python 3.12


Additional info:

Possibly fixed upstream by this commit:

https://github.com/cython/cython/commit/b4595a04a78b79dc59276a9f64aab7b884e945e8

Comment 1 Miro Hrončok 2022-12-22 01:20:46 UTC
Thanks for the report and a possible fix. I'll have a look at this after the holidays.

Comment 3 Ben Cotton 2023-02-07 15:13:16 UTC
This bug appears to have been reported against 'rawhide' during the Fedora Linux 38 development cycle.
Changing version to 38.