Bug 2069158
Summary: | python-giacpy fails to build with Python 3.11: error: cannot convert PyObject {aka _object} to PyTracebackObject {aka _traceback} in assignment | ||
---|---|---|---|
Product: | [Fedora] Fedora | Reporter: | Tomáš Hrnčiar <thrnciar> |
Component: | python-giacpy | Assignee: | Antonio T. sagitter <trpost> |
Status: | CLOSED RAWHIDE | QA Contact: | Fedora Extras Quality Assurance <extras-qa> |
Severity: | unspecified | Docs Contact: | |
Priority: | unspecified | ||
Version: | rawhide | CC: | frederic.han, mhroncok, thrnciar, trpost |
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: | 2022-06-22 11:49:14 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: | 2016048 |
Description
Tomáš Hrnčiar
2022-03-28 11:56:53 UTC
I need help of author. this code is generated by cython. With python3.9 don't see it in giacpy.cpp. it seems related to this part of cython: https://github.com/cython/cython/blob/master/Cython/Utility/Coroutine.c It is not clear to me which part of giacpy.pyx makes cython use this. Do you have success to build sagemath with python3.11? Hello Frederic, sagemath wasn't built with python3.11 so far, because there is a bunch of missing dependencies. I've tried to disable them by flipping bconds and triggered the build. The results will be available here: https://copr.fedorainfracloud.org/coprs/build/3910840 . (In reply to Frederic Han from comment #2) > this code is generated by cython. With python3.9 don't see it in giacpy.cpp. > > it seems related to this part of cython: > > https://github.com/cython/cython/blob/master/Cython/Utility/Coroutine.c Beware, in Fedora we are using the stable branch of Cython (0.29.x) and it might differ from the master branch. https://github.com/cython/cython/blob/0.29.x/Cython/Utility/Coroutine.c It's also possible that the bug is in Cython. Coroutine.c file was already modified to accommodate Python 3.11 so maybe it will need some further changes. I think it may be already solved in cython's master branch. I have done the following test: in the broken file giacpy.cpp I have replaced a couple of lines in Pyx_Coroutine_SendEx with the code from coroutine.c in master branch of cython and it worked. {{{ diff --git a/giacpy-auto-p311.cpp b/giacpy.cpp index ce79a80..21a4f79 100644 --- a/giacpy-auto-p311.cpp +++ b/giacpy.cpp @@ -164180,21 +164180,29 @@ PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value, i if (exc_state->exc_value) { #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON #else - PyTracebackObject *tb; - #if PY_VERSION_HEX >= 0x030B00A4 - tb = __Pyx__ExceptionGetTraceback(exc_state->exc_value); + PyObject *exc_tb; + #if PY_VERSION_HEX >= 0x030B00a4 + // owned reference! + exc_tb = PyException_GetTraceback(exc_state->exc_value); #else - tb = exc_state->exc_traceback; + exc_tb = exc_state->exc_traceback; #endif - if (tb) { + if (exc_tb) { + PyTracebackObject *tb = (PyTracebackObject *) exc_tb; PyFrameObject *f = tb->tb_frame; + assert(f->f_back == NULL); #if PY_VERSION_HEX >= 0x030B00A1 + // PyThreadState_GetFrame returns NULL if there isn't a current frame + // which is a valid state so no need to check f->f_back = PyThreadState_GetFrame(tstate); #else Py_XINCREF(tstate->frame); f->f_back = tstate->frame; #endif + #if PY_VERSION_HEX >= 0x030B00a4 + Py_DECREF(exc_tb); + #endif } #endif }}} so I think that a cython upgrade shoud solve this. Best Frederic So I can confirm that the changes we need appear in this commit of Coroutine.c Adapt to "exc_info" changes in CPython 3.11a4: https://github.com/cython/cython/commit/776957022d062ed24edea192b719720118ee3576 I was able to modify Coroutine.c and cythonize giacpy in mock with python3.11 and build giacpy. More precisely we need at least the folling changes: {{{ diff Coroutine.c.orig Coroutine.c 724,726c724,727 < PyTracebackObject *tb; < #if PY_VERSION_HEX >= 0x030B00A4 < tb = __Pyx__ExceptionGetTraceback(exc_state->exc_value); --- > PyObject *exc_tb; > #if PY_VERSION_HEX >= 0x030B00a4 > // owned reference! > exc_tb = PyException_GetTraceback(exc_state->exc_value); 728c729 < tb = exc_state->exc_traceback; --- > exc_tb = exc_state->exc_traceback; 730c731,732 < if (tb) { --- > if (exc_tb) { > PyTracebackObject *tb = (PyTracebackObject *) exc_tb; 741a744,746 > #if PY_VERSION_HEX >= 0x030B00a4 > Py_DECREF(exc_tb); > #endif 745c750 }}} Closing this in bulk as it built with Python 3.11. If this needs to remain open for a followup, feel free to reopen, I won't close in bulk again. |