Bug 1808343

Summary: libxml2 fails to build with Python 3.9: python/libxml.c:297:37: error: expected ';' before '{' token
Product: [Fedora] Fedora Reporter: Miro Hrončok <mhroncok>
Component: libxml2Assignee: Igor Raits <igor.raits>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: c.david86, cstratak, igor.raits, jpokorny, mhroncok, mplch, pviktori, veillard
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: 2020-03-05 14:12:04 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: 1785415    

Description Miro Hrončok 2020-02-28 09:50:01 UTC
libxml2 fails to build with Python 3.9.0a4.

/usr/include/python3.9/object.h:623:41: error: expected '(' before 'PyType_HasFeature'
  623 | #define PyType_FastSubclass(type, flag) PyType_HasFeature(type, flag)
      |                                         ^~~~~~~~~~~~~~~~~
/usr/include/python3.9/unicodeobject.h:115:18: note: in expansion of macro 'PyType_FastSubclass'
  115 |                  PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_UNICODE_SUBCLASS)
      |                  ^~~~~~~~~~~~~~~~~~~
../../python/libxml.c:297:15: note: in expansion of macro 'PyUnicode_Check'
  297 |     } else if PyUnicode_Check (ret) {
      |               ^~~~~~~~~~~~~~~
../../python/libxml.c:297:37: error: expected ';' before '{' token
  297 |     } else if PyUnicode_Check (ret) {
      |                                     ^
../../python/libxml.c: In function 'xmlPythonFileRead':
../../python/libxml.c:354:5: warning: 'PyEval_CallMethod' is deprecated [-Wdeprecated-declarations]
  354 |     ret = PyEval_CallMethod(file, (char *) "io_read", (char *) "(i)", len);
      |     ^~~
In file included from /usr/include/python3.9/Python.h:141,
                 from ../../python/libxml.c:14:
/usr/include/python3.9/ceval.h:28:43: note: declared here
   28 | Py_DEPRECATED(3.9) PyAPI_FUNC(PyObject *) PyEval_CallMethod(
      |                                           ^~~~~~~~~~~~~~~~~
In file included from /usr/include/python3.9/pytime.h:6,
                 from /usr/include/python3.9/Python.h:85,
                 from ../../python/libxml.c:14:
/usr/include/python3.9/object.h:623:41: error: expected '(' before 'PyType_HasFeature'
  623 | #define PyType_FastSubclass(type, flag) PyType_HasFeature(type, flag)
      |                                         ^~~~~~~~~~~~~~~~~
/usr/include/python3.9/unicodeobject.h:115:18: note: in expansion of macro 'PyType_FastSubclass'
  115 |                  PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_UNICODE_SUBCLASS)
      |                  ^~~~~~~~~~~~~~~~~~~
../../python/libxml.c:362:15: note: in expansion of macro 'PyUnicode_Check'
  362 |     } else if PyUnicode_Check (ret) {
      |               ^~~~~~~~~~~~~~~
../../python/libxml.c:362:37: error: expected ';' before '{' token
  362 |     } else if PyUnicode_Check (ret) {
      |    

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.9/fedora-rawhide-x86_64/01255332-libxml2/

For all our attempts to build libxml2 with Python 3.9, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.9/package/libxml2/

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.9:
https://copr.fedorainfracloud.org/coprs/g/python/python3.9/

Let us know here if you have any questions.

Python 3.9 will be included in Fedora 33. To make that update smoother, we're building Fedora packages with early pre-releases of Python 3.9.
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 Petr Viktorin (pviktori) 2020-02-28 10:20:27 UTC
In C, `if` expressions should be parenthesized, so that line should read:

    } else if (PyUnicode_Check (ret)) {

I guess PyUnicode_Check happened to expand to a parenthesized expression before, but that's not API to rely on.