Bug 2247010

Summary: python-multidict fails to build with Python 3.13: implicit declaration of function 'Py_TRASHCAN_SAFE_BEGIN', '‘Py_TRASHCAN_SAFE_END’', ‘_PyArg_ParseStackAndKeywords’; unknown type name ‘_PyArg_Parser’
Product: [Fedora] Fedora Reporter: Karolina Surma <ksurma>
Component: python-multidictAssignee: Carl George 🎩 <carl>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 40CC: carl, code, fweimer, igor.raits, ksurma, mail, mhroncok
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: 2024-04-13 12:18:38 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: 2137512, 2244836    

Description Karolina Surma 2023-10-30 11:56:06 UTC
python-multidict fails to build with Python 3.13.0a1.

  multidict/_multilib/defs.h:8:1: error: type defaults to ‘int’ in declaration of ‘_Py_IDENTIFIER’ [-Werror=implicit-int]

  multidict/_multilib/istr.h:46:8: error: implicit declaration of function ‘_PyObject_CallMethodId’; did you mean ‘PyObject_CallMethod’? [-Werror=implicit-function-declaration]
     46 |     s =_PyObject_CallMethodId(ret, &PyId_lower, NULL);
        |        ^~~~~~~~~~~~~~~~~~~~~~
        |        PyObject_CallMethod

  multidict/_multilib/istr.h:46:37: error: ‘PyId_lower’ undeclared (first use in this function)
     46 |     s =_PyObject_CallMethodId(ret, &PyId_lower, NULL);
        |                                     ^~~~~~~~~~
  multidict/_multidict.c:712:5: error: implicit declaration of function ‘Py_TRASHCAN_SAFE_BEGIN’; did you mean ‘Py_TRASHCAN_BEGIN’? [-Werror=implicit-function-declaration]
    712 |     Py_TRASHCAN_SAFE_BEGIN(self);
        |     ^~~~~~~~~~~~~~~~~~~~~~
        |     Py_TRASHCAN_BEGIN
  multidict/_multidict.c:718:5: error: implicit declaration of function ‘Py_TRASHCAN_SAFE_END’; did you mean ‘Py_TRASHCAN_END’? [-Werror=implicit-function-declaration]
    718 |     Py_TRASHCAN_SAFE_END(self);
        |     ^~~~~~~~~~~~~~~~~~~~
        |     Py_TRASHCAN_END

- ‘_Py_IDENTIFIER’ has been removed from Python 3.13.
The detailed list of the removed private C API functions can be found here:
https://github.com/python/cpython/issues/106320
- Remove the old trashcan macros Py_TRASHCAN_SAFE_BEGIN and Py_TRASHCAN_SAFE_END. They should be replaced by the new macros Py_TRASHCAN_BEGIN and Py_TRASHCAN_END. The new macros were added in Python 3.8 and the old macros were deprecated in Python 3.11. (Contributed by Irit Katriel in gh-105111.)

https://docs.python.org/3.13/whatsnew/3.13.html

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.13/fedora-rawhide-x86_64/06578835-python-multidict/

For all our attempts to build python-multidict with Python 3.13, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.13/package/python-multidict/

Testing and mass rebuild of packages is happening in copr.
You can follow these instructions to test locally in mock if your package builds with Python 3.13:
https://copr.fedorainfracloud.org/coprs/g/python/python3.13/

Let us know here if you have any questions.

Python 3.13 is planned to be included in Fedora 41.
To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.13.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires),
so if this package is required a lot, it's important for us to get it fixed soon.

We'd appreciate help from the people who know this package best,
but if you don't want to work on this now, let us know so we can try to work around it on our side.

Comment 1 Karolina Surma 2023-11-21 11:29:44 UTC
There have been multiple reverts in after Python 3.12~alpha1 and now python-multidict fails to build with those errors:

- multiple times in multiple functions:
 multidict/_multidict.c: In function ‘multidict_getall’:
  multidict/_multidict.c:452:12: error: unknown type name ‘_PyArg_Parser’
    452 |     static _PyArg_Parser _parser = {"O|O:getall", _keywords, 0};
        |            ^~~~~~~~~~~~~

  multidict/_multidict.c:453:10: error: implicit declaration of function ‘_PyArg_ParseStackAndKeywords’; did you mean ‘PyArg_ParseTupleAndKeywords’? [-Werror=implicit-function-declaration]
    453 |     if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
        |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
        |          PyArg_ParseTupleAndKeywords

Comment 2 Ben Beasley 2023-12-05 13:50:50 UTC
It’s possible to work around this by disabling the C extensions, at a significant performance cost: https://src.fedoraproject.org/rpms/python-multidict/pull-request/4

This may still be worth it until upstream can deal with the issue.

Comment 3 Florian Weimer 2024-01-03 20:25:34 UTC
This package is already quite broken with Python 3.12:

$ python3
Python 3.12.1 (main, Dec 18 2023, 00:00:00) [GCC 13.2.1 20231205 (Red Hat 13.2.1-6)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import multidict
>>> m = multidict.MultiDict()
>>> m.getall()
Segmentation fault (core dumped)

The internal _PyArg_Parser struct changed its members, so the initializer no longer works correctly. GCC 13 and earlier ignore the resulting C type errors, but GCC 14 will refuse to compile this by default, and rightly so, given that the code  results in crashes at run time.

Comment 4 Miro Hrončok 2024-01-25 13:53:57 UTC
See also https://github.com/aio-libs/multidict/issues/926 which started as a report of build failures with GCC 14, but turned out it "misbuilt" with GCC 13.

Comment 5 Aoife Moloney 2024-02-15 23:02:42 UTC
This bug appears to have been reported against 'rawhide' during the Fedora Linux 40 development cycle.
Changing version to 40.

Comment 6 Ben Beasley 2024-04-13 12:18:38 UTC
Based on the successful build https://copr.fedorainfracloud.org/coprs/g/python/python3.13/build/7290479/, this was fixed by updating to 6.0.5 in https://bodhi.fedoraproject.org/updates/FEDORA-2024-4ac6ca5505.