Bug 2057404 - HepMC3 fails to build with Python 3.11: error: 'PyFrameObject' {aka 'struct _frame'} has no member named 'f_code'
Summary: HepMC3 fails to build with Python 3.11: error: 'PyFrameObject' {aka 'struct _...
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: HepMC3
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Mattias Ellert
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
: 2098662 (view as bug list)
Depends On:
Blocks: PYTHON3.11 F37FTBFS F37FailsToInstall
TreeView+ depends on / blocked
 
Reported: 2022-02-23 10:42 UTC by Tomáš Hrnčiar
Modified: 2022-06-21 05:32 UTC (History)
3 users (show)

Fixed In Version: HepMC3-3.2.5-4.fc37
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-06-21 05:32:14 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Tomáš Hrnčiar 2022-02-23 10:42:37 UTC
HepMC3 fails to build with Python 3.11.0a4.

/builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/cast.h:446:38: error: 'PyFrameObject' {aka 'struct _frame'} has no member named 'f_code'
  446 |                 "  " + handle(frame->f_code->co_filename).cast<std::string>() +
      |                                      ^~~~~~
/builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/cast.h:446:75: error: expected primary-expression before '>' token
  446 |                 "  " + handle(frame->f_code->co_filename).cast<std::string>() +
      |                                                                           ^
/builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/cast.h:446:77: error: expected primary-expression before ')' token
  446 |                 "  " + handle(frame->f_code->co_filename).cast<std::string>() +
      |                                                                             ^
/builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/cast.h:448:31: error: 'PyFrameObject' {aka 'struct _frame'} has no member named 'f_code'
  448 |                 handle(frame->f_code->co_name).cast<std::string>() + "\n";
      |                               ^~~~~~
/builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/cast.h:448:64: error: expected primary-expression before '>' token
  448 |                 handle(frame->f_code->co_name).cast<std::string>() + "\n";
      |                                                                ^
/builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/cast.h:448:66: error: expected primary-expression before ')' token
  448 |                 handle(frame->f_code->co_name).cast<std::string>() + "\n";
      |                                                                  ^
/builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/pybind11.h: In function 'pybind11::function pybind11::detail::get_type_override(const void*, const type_info*, const char*)':
/builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/pybind11.h:2213:49: error: 'PyThreadState' {aka 'struct _ts'} has no member named 'frame'; did you mean 'cframe'?
 2213 |     PyFrameObject *frame = PyThreadState_Get()->frame;
      |                                                 ^~~~~
      |                                                 cframe
/builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/pybind11.h:2214:43: error: 'PyFrameObject' {aka 'struct _frame'} has no member named 'f_code'
 2214 |     if (frame && (std::string) str(frame->f_code->co_name) == name &&
      |                                           ^~~~~~
/builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/pybind11.h:2215:16: error: 'PyFrameObject' {aka 'struct _frame'} has no member named 'f_code'
 2215 |         frame->f_code->co_argcount > 0) {
      |                ^~~~~~
/builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/pybind11.h:2218:20: error: 'PyFrameObject' {aka 'struct _frame'} has no member named 'f_locals'
 2218 |             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:58,
                 from /builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/detail/common.h:122,
                 from /builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/pytypes.h:12,
                 from /builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/cast.h:13:
/builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/pybind11.h:2218:54: error: 'PyFrameObject' {aka 'struct _frame'} has no member named 'f_code'
 2218 |             frame->f_locals, PyTuple_GET_ITEM(frame->f_code->co_varnames, 0));
      |                                                      ^~~~~~
In file included from /builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/attr.h:13,
                 from /builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/pybind11.h:45,
                 from /builddir/build/BUILD/HepMC3-3.2.5/python/src/pyHepMC3rootIO.cpp:7:
/builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/cast.h: In function 'std::string pybind11::detail::error_string()':
/builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/cast.h:446:38: error: 'PyFrameObject' {aka 'struct _frame'} has no member named 'f_code'
  446 |                 "  " + handle(frame->f_code->co_filename).cast<std::string>() +
      |                                      ^~~~~~
/builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/cast.h:446:75: error: expected primary-expression before '>' token
  446 |                 "  " + handle(frame->f_code->co_filename).cast<std::string>() +
      |                                                                           ^
/builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/cast.h:446:77: error: expected primary-expression before ')' token
  446 |                 "  " + handle(frame->f_code->co_filename).cast<std::string>() +
      |                                                                             ^
/builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/cast.h:448:31: error: 'PyFrameObject' {aka 'struct _frame'} has no member named 'f_code'
  448 |                 handle(frame->f_code->co_name).cast<std::string>() + "\n";
      |                               ^~~~~~
/builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/cast.h:448:64: error: expected primary-expression before '>' token
  448 |                 handle(frame->f_code->co_name).cast<std::string>() + "\n";
      |                                                                ^
/builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/cast.h:448:66: error: expected primary-expression before ')' token
  448 |                 handle(frame->f_code->co_name).cast<std::string>() + "\n";
      |                                                                  ^
/builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/pybind11.h: In function 'pybind11::function pybind11::detail::get_type_override(const void*, const type_info*, const char*)':
/builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/pybind11.h:2213:49: error: 'PyThreadState' {aka 'struct _ts'} has no member named 'frame'; did you mean 'cframe'?
 2213 |     PyFrameObject *frame = PyThreadState_Get()->frame;
      |                                                 ^~~~~
      |                                                 cframe
/builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/pybind11.h:2214:43: error: 'PyFrameObject' {aka 'struct _frame'} has no member named 'f_code'
 2214 |     if (frame && (std::string) str(frame->f_code->co_name) == name &&
      |                                           ^~~~~~
/builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/pybind11.h:2215:16: error: 'PyFrameObject' {aka 'struct _frame'} has no member named 'f_code'
 2215 |         frame->f_code->co_argcount > 0) {
      |                ^~~~~~
/builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/pybind11.h:2218:20: error: 'PyFrameObject' {aka 'struct _frame'} has no member named 'f_locals'
 2218 |             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:58,
                 from /builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/detail/common.h:122,
                 from /builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/pytypes.h:12,
                 from /builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/cast.h:13:
/builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/pybind11.h:2218:54: error: 'PyFrameObject' {aka 'struct _frame'} has no member named 'f_code'
 2218 |             frame->f_locals, PyTuple_GET_ITEM(frame->f_code->co_varnames, 0));
      |                                                      ^~~~~~
gmake[2]: *** [python/CMakeFiles/pyHepMC33.11.0.dir/build.make:79: python/CMakeFiles/pyHepMC33.11.0.dir/src/pyHepMC3.cpp.o] Error 1
gmake[2]: Leaving directory '/builddir/build/BUILD/HepMC3-3.2.5/redhat-linux-build'
gmake[1]: *** [CMakeFiles/Makefile2:1414: python/CMakeFiles/pyHepMC33.11.0.dir/all] Error 2
gmake[1]: *** Waiting for unfinished jobs....
[ 76%] Building CXX object python/CMakeFiles/pyHepMC3rootIO3.11.0.dir/src/pyHepMC3rootIO_0.cpp.o
cd /builddir/build/BUILD/HepMC3-3.2.5/redhat-linux-build/python && /usr/bin/g++ -DHEPMC3_ENABLE_SEARCH -DHEPMC3_ROOTIO -D_FORTIFY_SOURCE=2 -D_GLIBCXX_ASSERTIONS -DpyHepMC3rootIO3_11_0_EXPORTS -I/usr/include/root -I/builddir/build/BUILD/HepMC3-3.2.5/python/include -I/builddir/build/BUILD/HepMC3-3.2.5/include -I/builddir/build/BUILD/HepMC3-3.2.5/rootIO/include -I/builddir/build/BUILD/HepMC3-3.2.5/search/include -I/builddir/build/BUILD/HepMC3-3.2.5/python -isystem /usr/include/python3.11 -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64  -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -O2 -fexceptions -g -grecord-gcc-switches -pipe -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -std=c++17 -pipe -fsigned-char -pthread -Wno-strict-aliasing -Wno-unused-but-set-variable -Wno-unused-value -DNDEBUG -fPIC -std=c++17 -MD -MT python/CMakeFiles/pyHepMC3rootIO3.11.0.dir/src/pyHepMC3rootIO_0.cpp.o -MF CMakeFiles/pyHepMC3rootIO3.11.0.dir/src/pyHepMC3rootIO_0.cpp.o.d -o CMakeFiles/pyHepMC3rootIO3.11.0.dir/src/pyHepMC3rootIO_0.cpp.o -c /builddir/build/BUILD/HepMC3-3.2.5/python/src/pyHepMC3rootIO_0.cpp
gmake[2]: *** [python/CMakeFiles/pyHepMC3rootIO3.11.0.dir/build.make:79: python/CMakeFiles/pyHepMC3rootIO3.11.0.dir/src/pyHepMC3rootIO.cpp.o] Error 1
gmake[2]: *** Waiting for unfinished jobs....
In file included from /builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/attr.h:13,
                 from /builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/pybind11.h:45,
                 from /builddir/build/BUILD/HepMC3-3.2.5/python/src/pyHepMC3rootIO_0.cpp:11:
/builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/cast.h: In function 'std::string pybind11::detail::error_string()':
/builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/cast.h:446:38: error: 'PyFrameObject' {aka 'struct _frame'} has no member named 'f_code'
  446 |                 "  " + handle(frame->f_code->co_filename).cast<std::string>() +
      |                                      ^~~~~~
/builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/cast.h:446:75: error: expected primary-expression before '>' token
  446 |                 "  " + handle(frame->f_code->co_filename).cast<std::string>() +
      |                                                                           ^
/builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/cast.h:446:77: error: expected primary-expression before ')' token
  446 |                 "  " + handle(frame->f_code->co_filename).cast<std::string>() +
      |                                                                             ^
/builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/cast.h:448:31: error: 'PyFrameObject' {aka 'struct _frame'} has no member named 'f_code'
  448 |                 handle(frame->f_code->co_name).cast<std::string>() + "\n";
      |                               ^~~~~~
/builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/cast.h:448:64: error: expected primary-expression before '>' token
  448 |                 handle(frame->f_code->co_name).cast<std::string>() + "\n";
      |                                                                ^
/builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/cast.h:448:66: error: expected primary-expression before ')' token
  448 |                 handle(frame->f_code->co_name).cast<std::string>() + "\n";
      |                                                                  ^
/builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/pybind11.h: In function 'pybind11::function pybind11::detail::get_type_override(const void*, const type_info*, const char*)':
/builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/pybind11.h:2213:49: error: 'PyThreadState' {aka 'struct _ts'} has no member named 'frame'; did you mean 'cframe'?
 2213 |     PyFrameObject *frame = PyThreadState_Get()->frame;
      |                                                 ^~~~~
      |                                                 cframe
/builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/pybind11.h:2214:43: error: 'PyFrameObject' {aka 'struct _frame'} has no member named 'f_code'
 2214 |     if (frame && (std::string) str(frame->f_code->co_name) == name &&
      |                                           ^~~~~~
/builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/pybind11.h:2215:16: error: 'PyFrameObject' {aka 'struct _frame'} has no member named 'f_code'
 2215 |         frame->f_code->co_argcount > 0) {
      |                ^~~~~~
/builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/pybind11.h:2218:20: error: 'PyFrameObject' {aka 'struct _frame'} has no member named 'f_locals'
 2218 |             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:58,
                 from /builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/detail/common.h:122,
                 from /builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/pytypes.h:12,
                 from /builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/cast.h:13:
/builddir/build/BUILD/HepMC3-3.2.5/python/include/pybind11/pybind11.h:2218:54: error: 'PyFrameObject' {aka 'struct _frame'} has no member named 'f_code'
 2218 |             frame->f_locals, PyTuple_GET_ITEM(frame->f_code->co_varnames, 0));
      |                                                      ^~~~~~
gmake[2]: *** [python/CMakeFiles/pyHepMC3rootIO3.11.0.dir/build.make:93: python/CMakeFiles/pyHepMC3rootIO3.11.0.dir/src/pyHepMC3rootIO_0.cpp.o] Error 1

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((PyObject*)frame, "f_builtins").
    f_globals: removed, use PyObject_GetAttrString((PyObject*)frame, "f_globals").
    f_locals: removed, use PyObject_GetAttrString((PyObject*)frame, "f_locals").
    f_lasti: removed, use PyObject_GetAttrString((PyObject*)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/03534497-HepMC3/

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

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 Miro Hrončok 2022-06-20 10:14:44 UTC
*** Bug 2098662 has been marked as a duplicate of this bug. ***


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