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

Fixed In Version: dlib-19.24-1.fc34 dlib-19.24-1.fc36 dlib-19.24-1.fc35
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-05-19 01:00:40 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

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


/builddir/build/BUILD/dlib-19.23/dlib/external/pybind11/include/pybind11/cast.h: In function ‘std::string pybind11::detail::error_string()’:
/builddir/build/BUILD/dlib-19.23/dlib/external/pybind11/include/pybind11/cast.h:441:38: error: ‘PyFrameObject’ {aka ‘struct _frame’} has no member named ‘f_code’
  441 |                 "  " + handle(frame->f_code->co_filename).cast<std::string>() +
      |                                      ^~~~~~
/builddir/build/BUILD/dlib-19.23/dlib/external/pybind11/include/pybind11/cast.h:441:75: error: expected primary-expression before ‘>’ token
  441 |                 "  " + handle(frame->f_code->co_filename).cast<std::string>() +
      |                                                                           ^
/builddir/build/BUILD/dlib-19.23/dlib/external/pybind11/include/pybind11/cast.h:441:77: error: expected primary-expression before ‘)’ token
  441 |                 "  " + handle(frame->f_code->co_filename).cast<std::string>() +
      |                                                                             ^
/builddir/build/BUILD/dlib-19.23/dlib/external/pybind11/include/pybind11/cast.h:443:31: error: ‘PyFrameObject’ {aka ‘struct _frame’} has no member named ‘f_code’
  443 |                 handle(frame->f_code->co_name).cast<std::string>() + "\n";
      |                               ^~~~~~
/builddir/build/BUILD/dlib-19.23/dlib/external/pybind11/include/pybind11/cast.h:443:64: error: expected primary-expression before ‘>’ token
  443 |                 handle(frame->f_code->co_name).cast<std::string>() + "\n";
      |                                                                ^
/builddir/build/BUILD/dlib-19.23/dlib/external/pybind11/include/pybind11/cast.h:443:66: error: expected primary-expression before ‘)’ token
  443 |                 handle(frame->f_code->co_name).cast<std::string>() + "\n";
      |                                                                  ^
In file included from /builddir/build/BUILD/dlib-19.23/dlib/external/pybind11/include/pybind11/cast.h:16,
                 from /builddir/build/BUILD/dlib-19.23/dlib/external/pybind11/include/pybind11/attr.h:13,
                 from /builddir/build/BUILD/dlib-19.23/dlib/external/pybind11/include/pybind11/pybind11.h:43,
                 from /builddir/build/BUILD/dlib-19.23/dlib/../dlib/python/pybind_utils.h:6,
                 from /builddir/build/BUILD/dlib-19.23/dlib/../dlib/python.h:6,
                 from /builddir/build/BUILD/dlib-19.23/tools/python/src/opaque_types.h:6,
                 from /builddir/build/BUILD/dlib-19.23/tools/python/src/matrix.cpp:4:
/builddir/build/BUILD/dlib-19.23/dlib/external/pybind11/include/pybind11/detail/internals.h: In function ‘pybind11::detail::internals& pybind11::detail::get_internals()’:
/builddir/build/BUILD/dlib-19.23/dlib/external/pybind11/include/pybind11/detail/internals.h:194:27: warning: ‘void PyEval_InitThreads()’ is deprecated [-Wdeprecated-declarations]
  194 |         PyEval_InitThreads();
      |         ~~~~~~~~~~~~~~~~~~^~
In file included from /usr/include/python3.11/Python.h:93,
                 from /builddir/build/BUILD/dlib-19.23/dlib/external/pybind11/include/pybind11/detail/common.h:112,
                 from /builddir/build/BUILD/dlib-19.23/dlib/external/pybind11/include/pybind11/pytypes.h:12,
                 from /builddir/build/BUILD/dlib-19.23/dlib/external/pybind11/include/pybind11/cast.h:13:
/usr/include/python3.11/ceval.h:132:37: note: declared here
  132 | Py_DEPRECATED(3.9) PyAPI_FUNC(void) PyEval_InitThreads(void);
      |                                     ^~~~~~~~~~~~~~~~~~
/builddir/build/BUILD/dlib-19.23/dlib/external/pybind11/include/pybind11/pybind11.h: In function ‘pybind11::function pybind11::get_type_overload(const void*, const detail::type_info*, const char*)’:
/builddir/build/BUILD/dlib-19.23/dlib/external/pybind11/include/pybind11/pybind11.h:1890:49: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘frame’; did you mean ‘cframe’?
 1890 |     PyFrameObject *frame = PyThreadState_Get()->frame;
      |                                                 ^~~~~
      |                                                 cframe
/builddir/build/BUILD/dlib-19.23/dlib/external/pybind11/include/pybind11/pybind11.h:1891:43: error: ‘PyFrameObject’ {aka ‘struct _frame’} has no member named ‘f_code’
 1891 |     if (frame && (std::string) str(frame->f_code->co_name) == name &&
      |                                           ^~~~~~
/builddir/build/BUILD/dlib-19.23/dlib/external/pybind11/include/pybind11/pybind11.h:1892:16: error: ‘PyFrameObject’ {aka ‘struct _frame’} has no member named ‘f_code’
 1892 |         frame->f_code->co_argcount > 0) {
      |                ^~~~~~
/builddir/build/BUILD/dlib-19.23/dlib/external/pybind11/include/pybind11/pybind11.h:1895:20: error: ‘PyFrameObject’ {aka ‘struct _frame’} has no member named ‘f_locals’
 1895 |             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/dlib-19.23/dlib/external/pybind11/include/pybind11/pybind11.h:1895:54: error: ‘PyFrameObject’ {aka ‘struct _frame’} has no member named ‘f_code’
 1895 |             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/dlib-19.23/dlib/external/pybind11/include/pybind11/pybind11.h:1895:30: note: in expansion of macro ‘PyTuple_GET_ITEM’
 1895 |             frame->f_locals, PyTuple_GET_ITEM(frame->f_code->co_varnames, 0));
      |                              ^~~~~~~~~~~~~~~~
/builddir/build/BUILD/dlib-19.23/dlib/external/pybind11/include/pybind11/cast.h: In function ‘std::string pybind11::detail::error_string()’:
/builddir/build/BUILD/dlib-19.23/dlib/external/pybind11/include/pybind11/cast.h:441:38: error: ‘PyFrameObject’ {aka ‘struct _frame’} has no member named ‘f_code’
  441 |                 "  " + handle(frame->f_code->co_filename).cast<std::string>() +
      |                                      ^~~~~~
/builddir/build/BUILD/dlib-19.23/dlib/external/pybind11/include/pybind11/cast.h:441:75: error: expected primary-expression before ‘>’ token
  441 |                 "  " + handle(frame->f_code->co_filename).cast<std::string>() +
      |                                                                           ^
/builddir/build/BUILD/dlib-19.23/dlib/external/pybind11/include/pybind11/cast.h:441:77: error: expected primary-expression before ‘)’ token
  441 |                 "  " + handle(frame->f_code->co_filename).cast<std::string>() +
      |                                                                             ^
/builddir/build/BUILD/dlib-19.23/dlib/external/pybind11/include/pybind11/cast.h:443:31: error: ‘PyFrameObject’ {aka ‘struct _frame’} has no member named ‘f_code’
  443 |                 handle(frame->f_code->co_name).cast<std::string>() + "\n";
      |                               ^~~~~~
/builddir/build/BUILD/dlib-19.23/dlib/external/pybind11/include/pybind11/cast.h:443:64: error: expected primary-expression before ‘>’ token
  443 |                 handle(frame->f_code->co_name).cast<std::string>() + "\n";
      |                                                                ^
/builddir/build/BUILD/dlib-19.23/dlib/external/pybind11/include/pybind11/cast.h:443:66: error: expected primary-expression before ‘)’ token
  443 |                 handle(frame->f_code->co_name).cast<std::string>() + "\n";
      |                                                                  ^
/builddir/build/BUILD/dlib-19.23/dlib/external/pybind11/include/pybind11/pybind11.h: In function ‘pybind11::function pybind11::get_type_overload(const void*, const detail::type_info*, const char*)’:
/builddir/build/BUILD/dlib-19.23/dlib/external/pybind11/include/pybind11/pybind11.h:1890:49: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘frame’; did you mean ‘cframe’?
 1890 |     PyFrameObject *frame = PyThreadState_Get()->frame;
      |                                                 ^~~~~
      |                                                 cframe
/builddir/build/BUILD/dlib-19.23/dlib/external/pybind11/include/pybind11/pybind11.h:1891:43: error: ‘PyFrameObject’ {aka ‘struct _frame’} has no member named ‘f_code’
 1891 |     if (frame && (std::string) str(frame->f_code->co_name) == name &&
      |                                           ^~~~~~
/builddir/build/BUILD/dlib-19.23/dlib/external/pybind11/include/pybind11/pybind11.h:1892:16: error: ‘PyFrameObject’ {aka ‘struct _frame’} has no member named ‘f_code’
 1892 |         frame->f_code->co_argcount > 0) {
      |                ^~~~~~
/builddir/build/BUILD/dlib-19.23/dlib/external/pybind11/include/pybind11/pybind11.h:1895:20: error: ‘PyFrameObject’ {aka ‘struct _frame’} has no member named ‘f_locals’
 1895 |             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/dlib-19.23/dlib/external/pybind11/include/pybind11/pybind11.h:1895:54: error: ‘PyFrameObject’ {aka ‘struct _frame’} has no member named ‘f_code’
 1895 |             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/03270596-dlib/

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

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:18:13 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-05-10 07:39:31 UTC
FEDORA-2022-9cf243c869 has been submitted as an update to Fedora 35. https://bodhi.fedoraproject.org/updates/FEDORA-2022-9cf243c869

Comment 3 Fedora Update System 2022-05-10 07:39:34 UTC
FEDORA-2022-216876ff34 has been submitted as an update to Fedora 34. https://bodhi.fedoraproject.org/updates/FEDORA-2022-216876ff34

Comment 4 Fedora Update System 2022-05-10 07:39:37 UTC
FEDORA-2022-ea138b11d8 has been submitted as an update to Fedora 36. https://bodhi.fedoraproject.org/updates/FEDORA-2022-ea138b11d8

Comment 5 Fedora Update System 2022-05-11 02:37:44 UTC
FEDORA-2022-ea138b11d8 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-ea138b11d8`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2022-ea138b11d8

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

Comment 6 Fedora Update System 2022-05-11 02:45:18 UTC
FEDORA-2022-9cf243c869 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-9cf243c869`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2022-9cf243c869

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

Comment 7 Fedora Update System 2022-05-11 03:16:54 UTC
FEDORA-2022-216876ff34 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-216876ff34`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2022-216876ff34

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

Comment 8 Fedora Update System 2022-05-19 01:00:40 UTC
FEDORA-2022-216876ff34 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-05-19 01:16:56 UTC
FEDORA-2022-ea138b11d8 has been pushed to the Fedora 36 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 10 Fedora Update System 2022-05-19 01:22:34 UTC
FEDORA-2022-9cf243c869 has been pushed to the Fedora 35 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.