Bug 2062144 - sip fails to build with Python 3.11: error: invalid use of undefined type 'struct _frame'
Summary: sip fails to build with Python 3.11: error: invalid use of undefined type 'st...
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: sip
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
urgent
Target Milestone: ---
Assignee: Miro Hrončok
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.11
TreeView+ depends on / blocked
 
Reported: 2022-03-09 09:47 UTC by Tomáš Hrnčiar
Modified: 2022-06-17 10:59 UTC (History)
4 users (show)

Fixed In Version: sip-4.19.25-4.fc37
Clone Of:
Environment:
Last Closed: 2022-06-17 10:59:16 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Tomáš Hrnčiar 2022-03-09 09:47:11 UTC
sip fails to build with Python 3.11.0a5.

/builddir/build/BUILD/sip-4.19.25/siplib/siplib.c: In function 'sip_api_get_frame':
/builddir/build/BUILD/sip-4.19.25/siplib/siplib.c:13750:22: error: invalid use of undefined type 'struct _frame'
13750 |         frame = frame->f_back;
      |                      ^~

The PyFrameObject structure member has been moved to the internal C API headers.

While the documentation notes that the PyFrameObject fields are subject to change at any time, they have been stable for a long time and were used in several popular extensions.

In Python 3.11, the frame struct was reorganized to allow performance optimizations. Some fields were removed entirely, as they were details of the old implementation.

PyFrameObject fields:
    f_back: use PyFrame_GetBack().
    f_blockstack: removed.
    f_builtins: use PyObject_GetAttrString((PyObject*)frame, "f_builtins").
    f_code: use PyFrame_GetCode().
    f_gen: removed.
    f_globals: use PyObject_GetAttrString((PyObject*)frame, "f_globals").
    f_iblock: removed.
    f_lasti: use PyObject_GetAttrString((PyObject*)frame, "f_lasti"). Code using f_lasti with PyCode_Addr2Line() must use PyFrame_GetLineNumber() instead.
    f_lineno: use PyFrame_GetLineNumber()
    f_locals: use PyObject_GetAttrString((PyObject*)frame, "f_locals").
    f_stackdepth: removed.
    f_state: no public API (renamed to f_frame.f_state).
    f_trace: no public API.
    f_trace_lines: use PyObject_GetAttrString((PyObject*)frame, "f_trace_lines") (it also be modified).
    f_trace_opcodes: use PyObject_GetAttrString((PyObject*)frame, "f_trace_opcodes") (it also be modified).
    f_localsplus: no public API (renamed to f_frame.localsplus).
    f_valuestack: removed.

The Python frame object is now created lazily. A side effect is that the f_back member must not be accessed directly, since its value is now also computed lazily. The PyFrame_GetBack() function must be called instead.

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

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.11/fedora-rawhide-x86_64/03639868-sip/

For all our attempts to build sip with Python 3.11, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.11/package/sip/

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

Let us know here if you have any questions.

Python 3.11 is planned to be included in Fedora 37. To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.11.
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 Scott Talbert 2022-03-09 15:11:50 UTC
Note: upstream is no longer supporting sip 4, so we'll probably have to patch this downstream.  Might be a good idea to shoo more users away from sip 4, but PyQt4 may not be able to move easily?

Comment 2 Miro Hrončok 2022-06-17 10:38:22 UTC
This blocks at least 7 packages directly and more indirectly.

The Python 3.11 rebuild is almost done.

Comment 3 Miro Hrončok 2022-06-17 10:48:53 UTC
> Might be a good idea to shoo more users away from sip 4, but PyQt4 may not be able to move easily?

As a side note, Scott, would you know how to move libsavitar, libarcus, and python-pynest2d forward? They are from the cura stack and Cura uses PyQt5 on runtime, so I suppose they don't need sip 4, but since they use cmake I have no idea how to properly use sip 5 (or 6?). Thanks.

Comment 4 Miro Hrončok 2022-06-17 10:55:13 UTC
Testing a build with:

diff --git a/siplib/siplib.c b/siplib/siplib.c
index db52b68..8019e97 100644
--- a/siplib/siplib.c
+++ b/siplib/siplib.c
@@ -13747,7 +13747,7 @@ static struct _frame *sip_api_get_frame(int depth)
 
     while (frame != NULL && depth > 0)
     {
-        frame = frame->f_back;
+        frame = PyFrame_GetBack(frame);
         --depth;
     }


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