Bug 2050145 - trellis fails to build with Python 3.11: error: 'PyFrameObject' {aka 'struct _frame'} has no member named 'f_code'
Summary: trellis fails to build with Python 3.11: error: 'PyFrameObject' {aka 'struct ...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: trellis
Version: 36
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Gabriel Somlo
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.11
TreeView+ depends on / blocked
 
Reported: 2022-02-03 10:58 UTC by Tomáš Hrnčiar
Modified: 2022-03-26 15:00 UTC (History)
4 users (show)

Fixed In Version: trellis-1.2.1-1.20220222git3ae21cf.fc34 trellis-1.2.1-1.20220222git3ae21cf.fc35 trellis-1.2.1-1.20220222git3ae21cf.fc36
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-03-03 15:50:53 UTC
Type: Bug


Attachments (Terms of Use)

Description Tomáš Hrnčiar 2022-02-03 10:58:29 UTC
trellis fails to build with Python 3.11.0a4.

/builddir/build/BUILD/prjtrellis-2f06397673bbca3da11928d538b8ab7d01c944c6/libtrellis/3rdparty/pybind11/include/pybind11/pybind11.h: In function 'pybind11::function pybind11::detail::get_type_override(const void*, const type_info*, const char*)':
/builddir/build/BUILD/prjtrellis-2f06397673bbca3da11928d538b8ab7d01c944c6/libtrellis/3rdparty/pybind11/include/pybind11/pybind11.h:2218:49: error: 'PyThreadState' {aka 'struct _ts'} has no member named 'frame'; did you mean 'cframe'?
 2218 |     PyFrameObject *frame = PyThreadState_Get()->frame;
      |                                                 ^~~~~
      |                                                 cframe
/builddir/build/BUILD/prjtrellis-2f06397673bbca3da11928d538b8ab7d01c944c6/libtrellis/3rdparty/pybind11/include/pybind11/pybind11.h:2219:43: error: 'PyFrameObject' {aka 'struct _frame'} has no member named 'f_code'
 2219 |     if (frame && (std::string) str(frame->f_code->co_name) == name &&
      |                                           ^~~~~~
/builddir/build/BUILD/prjtrellis-2f06397673bbca3da11928d538b8ab7d01c944c6/libtrellis/3rdparty/pybind11/include/pybind11/pybind11.h:2220:16: error: 'PyFrameObject' {aka 'struct _frame'} has no member named 'f_code'
 2220 |         frame->f_code->co_argcount > 0) {
      |                ^~~~~~
/builddir/build/BUILD/prjtrellis-2f06397673bbca3da11928d538b8ab7d01c944c6/libtrellis/3rdparty/pybind11/include/pybind11/pybind11.h:2223:20: error: 'PyFrameObject' {aka 'struct _frame'} has no member named 'f_locals'
 2223 |             frame->f_locals, PyTuple_GET_ITEM(frame->f_code->co_varnames, 0));
      |                    ^~~~~~~~
In file included from /usr/include/python3.11/Python.h:35,
                 from /builddir/build/BUILD/prjtrellis-2f06397673bbca3da11928d538b8ab7d01c944c6/libtrellis/3rdparty/pybind11/include/pybind11/detail/common.h:122,
                 from /builddir/build/BUILD/prjtrellis-2f06397673bbca3da11928d538b8ab7d01c944c6/libtrellis/3rdparty/pybind11/include/pybind11/pytypes.h:12,
                 from /builddir/build/BUILD/prjtrellis-2f06397673bbca3da11928d538b8ab7d01c944c6/libtrellis/3rdparty/pybind11/include/pybind11/cast.h:13:
/builddir/build/BUILD/prjtrellis-2f06397673bbca3da11928d538b8ab7d01c944c6/libtrellis/3rdparty/pybind11/include/pybind11/pybind11.h:2223:54: error: 'PyFrameObject' {aka 'struct _frame'} has no member named 'f_code'
 2223 |             frame->f_locals, PyTuple_GET_ITEM(frame->f_code->co_varnames, 0));
      |                                                      ^~~~~~
/usr/include/python3.11/tupleobject.h:27:18: note: in expansion of macro 'PyType_FastSubclass'
   27 |                  PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_TUPLE_SUBCLASS)
      |                  ^~~~~~~~~~~~~~~~~~~
/usr/include/python3.11/object.h:140:30: note: in expansion of macro '_PyObject_CAST_CONST'
  140 | #define Py_TYPE(ob) _Py_TYPE(_PyObject_CAST_CONST(ob))
      |                              ^~~~~~~~~~~~~~~~~~~~
/usr/include/python3.11/tupleobject.h:27:38: note: in expansion of macro 'Py_TYPE'
   27 |                  PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_TUPLE_SUBCLASS)
      |                                      ^~~~~~~
/usr/include/python3.11/cpython/tupleobject.h:19:35: note: in expansion of macro 'PyTuple_Check'
   19 | #define _PyTuple_CAST(op) (assert(PyTuple_Check(op)), (PyTupleObject *)(op))
      |                                   ^~~~~~~~~~~~~
/usr/include/python3.11/cpython/tupleobject.h:23:34: note: in expansion of macro '_PyTuple_CAST'
   23 | #define PyTuple_GET_ITEM(op, i) (_PyTuple_CAST(op)->ob_item[i])
      |                                  ^~~~~~~~~~~~~
/builddir/build/BUILD/prjtrellis-2f06397673bbca3da11928d538b8ab7d01c944c6/libtrellis/3rdparty/pybind11/include/pybind11/pybind11.h:2223:30: note: in expansion of macro 'PyTuple_GET_ITEM'
 2223 |             frame->f_locals, PyTuple_GET_ITEM(frame->f_code->co_varnames, 0));
      |                              ^~~~~~~~~~~~~~~~
In file included from /usr/include/python3.11/tupleobject.h:39,
                 from /usr/include/python3.11/Python.h:57:
/builddir/build/BUILD/prjtrellis-2f06397673bbca3da11928d538b8ab7d01c944c6/libtrellis/3rdparty/pybind11/include/pybind11/pybind11.h:2223:54: error: 'PyFrameObject' {aka 'struct _frame'} has no member named 'f_code'
 2223 |             frame->f_locals, PyTuple_GET_ITEM(frame->f_code->co_varnames, 0));
      |                                                      ^~~~~~
/usr/include/python3.11/cpython/tupleobject.h:19:73: note: in definition of macro '_PyTuple_CAST'
   19 | #define _PyTuple_CAST(op) (assert(PyTuple_Check(op)), (PyTupleObject *)(op))
      |                                                                         ^~
/builddir/build/BUILD/prjtrellis-2f06397673bbca3da11928d538b8ab7d01c944c6/libtrellis/3rdparty/pybind11/include/pybind11/pybind11.h:2223:30: note: in expansion of macro 'PyTuple_GET_ITEM'
 2223 |             frame->f_locals, PyTuple_GET_ITEM(frame->f_code->co_varnames, 0));
      |                              ^~~~~~~~~~~~~~~~

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/03273144-trellis/

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

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 Ben Cotton 2022-02-08 20:17:45 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 36 development cycle.
Changing version to 36.

Comment 2 Fedora Update System 2022-02-23 14:18:00 UTC
FEDORA-2022-3a01291d36 has been submitted as an update to Fedora 36. https://bodhi.fedoraproject.org/updates/FEDORA-2022-3a01291d36

Comment 3 Fedora Update System 2022-02-23 14:18:12 UTC
FEDORA-2022-897cd392a5 has been submitted as an update to Fedora 35. https://bodhi.fedoraproject.org/updates/FEDORA-2022-897cd392a5

Comment 4 Fedora Update System 2022-02-23 14:18:50 UTC
FEDORA-2022-aa6b681e54 has been submitted as an update to Fedora 34. https://bodhi.fedoraproject.org/updates/FEDORA-2022-aa6b681e54

Comment 5 Fedora Update System 2022-02-23 15:50:55 UTC
FEDORA-2022-aa6b681e54 has been pushed to the Fedora 34 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2022-aa6b681e54`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2022-aa6b681e54

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 6 Fedora Update System 2022-02-23 16:08:37 UTC
FEDORA-2022-897cd392a5 has been pushed to the Fedora 35 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2022-897cd392a5`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2022-897cd392a5

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 7 Fedora Update System 2022-02-24 01:45:29 UTC
FEDORA-2022-3a01291d36 has been pushed to the Fedora 36 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2022-3a01291d36`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2022-3a01291d36

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 8 Fedora Update System 2022-03-03 15:50:53 UTC
FEDORA-2022-aa6b681e54 has been pushed to the Fedora 34 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 9 Fedora Update System 2022-03-03 16:08:20 UTC
FEDORA-2022-897cd392a5 has been pushed to the Fedora 35 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 10 Fedora Update System 2022-03-26 15:00:25 UTC
FEDORA-2022-3a01291d36 has been pushed to the Fedora 36 stable repository.
If problem still persists, please make note of it in this bug report.


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