Bug 2050102

Summary: python-gstreamer1 fails to build with Python 3.11: error: PyFrameObject {aka struct _frame} has no member named f_code
Product: [Fedora] Fedora Reporter: Tomáš Hrnčiar <thrnciar>
Component: python-gstreamer1Assignee: Simon Farnsworth <simon>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: gwync, mhroncok, simon, thrnciar, wtaymans
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-02-04 20:00:08 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-02-03 09:14:06 UTC
python-gstreamer1 fails to build with Python 3.11.0a4.

../gi/overrides/gstmodule.c:691:41: error: ‘PyFrameObject’ {aka ‘struct _frame’} has no member named ‘f_code’
  691 |     utf8 = PyUnicode_AsUTF8String (frame->f_code->co_name);
      |                                         ^~
../gi/overrides/gstmodule.c:697:41: error: ‘PyFrameObject’ {aka ‘struct _frame’} has no member named ‘f_code’
  697 |     utf8 = PyUnicode_AsUTF8String (frame->f_code->co_filename);
      |                                         ^~
../gi/overrides/gstmodule.c:703:35: error: ‘PyFrameObject’ {aka ‘struct _frame’} has no member named ‘f_code’
  703 |   lineno = PyCode_Addr2Line (frame->f_code, frame->f_lasti);
      |                                   ^~
../gi/overrides/gstmodule.c:703:50: error: ‘PyFrameObject’ {aka ‘struct _frame’} has no member named ‘f_lasti’
  703 |   lineno = PyCode_Addr2Line (frame->f_code, frame->f_lasti);
      |                                                  ^~

Changes of the private PyFrameObject structure members.

While the documentation notes that the fields of PyFrameObject 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. Rather than reading the fields directly, extensions should use functions:
    f_code: removed, use PyFrame_GetCode() instead. Warning: the function returns a strong reference, need to call Py_DECREF().
    f_back: changed (see below), use PyFrame_GetBack().
    f_builtins: removed, use PyObject_GetAttrString(frame, "f_builtins").
    f_globals: removed, use PyObject_GetAttrString(frame, "f_globals").
    f_locals: removed, use PyObject_GetAttrString(frame, "f_locals").
    f_lasti: removed, use PyObject_GetAttrString(frame, "f_lasti").

The following fields were removed entirely, as they were details of the old implementation:
    f_valuesstack
    f_stackdepth
    f_gen
    f_iblock
    f_state
    f_blockstack
    f_localsplus

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/03270913-python-gstreamer1/

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

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 Simon Farnsworth 2022-02-04 11:38:52 UTC
Raised upstream with https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/997

I will wait on upstream's guidance.

Comment 2 Simon Farnsworth 2022-02-04 20:00:00 UTC
There's a fix going in upstream. I'm going to close this, since it'll end up fixed on the normal update schedule when upstream release a new version.

I can also import the final MR when it's landed, if we don't get a new release between now and F37 opening up.