Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.
Bug 1941559 - python-cvxopt fails to build with Python 3.10: error: expected ‘(’ before ‘_PyObject_TypeCheck’
Summary: python-cvxopt fails to build with Python 3.10: error: expected ‘(’ before ‘_P...
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: python-cvxopt
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Jerry James
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.10
TreeView+ depends on / blocked
 
Reported: 2021-03-22 11:10 UTC by Miro Hrončok
Modified: 2021-03-22 21:24 UTC (History)
3 users (show)

Fixed In Version: python-cvxopt-1.2.6-2.fc35
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-03-22 15:18:58 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Miro Hrončok 2021-03-22 11:10:38 UTC
python-cvxopt fails to build with Python 3.10.0a6.

gcc -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fPIC -I/usr/include/python3.10 -c src/C/base.c -o build/temp.linux-x86_64-3.10/src/C/base.o
In file included from /usr/include/python3.10/Python.h:87,
                 from src/C/base.c:24:
src/C/base.c: In function ‘get_id’:
/usr/include/python3.10/object.h:242:38: error: expected ‘(’ before ‘_PyObject_TypeCheck’
  242 | #define PyObject_TypeCheck(ob, type) _PyObject_TypeCheck(_PyObject_CAST(ob), type)
      |                                      ^~~~~~~~~~~~~~~~~~~
src/C/cvxopt.h:73:28: note: in expansion of macro ‘PyObject_TypeCheck’
   73 | #define Matrix_Check(self) PyObject_TypeCheck(self, &matrix_tp)
      |                            ^~~~~~~~~~~~~~~~~~
src/C/base.c:356:8: note: in expansion of macro ‘Matrix_Check’
  356 |     if Matrix_Check((PyObject *)val)
      |        ^~~~~~~~~~~~
src/C/base.c:371:1: warning: control reaches end of non-void function [-Wreturn-type]
  371 | }
      | ^
error: command '/usr/bin/gcc' failed with exit code 1

I don't know exactly what changed in Python here, but will check.

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.10/fedora-rawhide-x86_64/02083694-python-cvxopt/

For all our attempts to build python-cvxopt with Python 3.10, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.10/package/python-cvxopt/

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

Let us know here if you have any questions.

Python 3.10 will be included in Fedora 35. To make that update smoother, we're building Fedora packages with early pre-releases of Python 3.10.
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 Jerry James 2021-03-22 14:29:16 UTC
Python 3.9 object.h includes this:

#define PyObject_TypeCheck(ob, tp) \
    (Py_IS_TYPE(ob, tp) || PyType_IsSubtype(Py_TYPE(ob), (tp)))

Python 3.10 object.h changes that to:

static inline int _PyObject_TypeCheck(PyObject *ob, PyTypeObject *type) {
    return Py_IS_TYPE(ob, type) || PyType_IsSubtype(Py_TYPE(ob), type);
}
#define PyObject_TypeCheck(ob, type) _PyObject_TypeCheck(_PyObject_CAST(ob), type)

and cvxopt.h has:

#define Matrix_Check(self) PyObject_TypeCheck(self, &matrix_tp)

So this code in cvxopt's base.c function:

if Matrix_Check((PyObject *)val)

used to expand to an expression in parentheses, but now it doesn't.  The cvxopt authors just need to wrap the "if" expression in parentheses and all will be well again.  I will contact upstream.

Comment 2 Miro Hrončok 2021-03-22 14:36:37 UTC
Indeed:

https://docs.python.org/3.10/whatsnew/changelog.html

"""Convert PyObject_TypeCheck() macro to a static inline function."""
https://bugs.python.org/issue43181


Thanks.

Comment 3 Jerry James 2021-03-22 15:02:45 UTC
https://github.com/cvxopt/cvxopt/pull/190

I will add that patch and kick off a Rawhide build.

Comment 4 Jerry James 2021-03-22 15:18:58 UTC
Patched version built in Rawhide.

Comment 5 Miro Hrončok 2021-03-22 21:24:29 UTC
As always, works like a charm. Thanks, Jerry!


Note You need to log in before you can comment on or make changes to this bug.