Python 3.11 gives SystemError: type Boost.Python.enum has the Py_TPFLAGS_HAVE_GC flag but has no traverse function

Open
#400 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp, python
Domain
api, backend

Research direction

Start in libs/python/src/object/enum.cpp at the Py_TPFLAGS_HAVE_GC line and reproduce the Python 3.11 import failure using the reported Boost 1.80 MSVC build. Compare behavior with and without that flag, then verify that the binding imports successfully on Python 3.11 without breaking the previously supported Python versions.

Written by the indexing model from the issue text.

Description

Up to Python 3.10 our Boost Python binding ran fine.
As of Python 3.11 we get the following error upon import of the binding;

SystemError: type Boost.Python.enum has the Py_TPFLAGS_HAVE_GC flag but has no traverse function

Running;
Python 3.11.0 (main, Oct 24 2022, 18:26:48) [MSC v.1933 64 bit (AMD64)] on win32
boost_1_80_0
b2 -j%NUMBER_OF_PROCESSORS% python=3.11 --with-python --stage-libdir=lib64-msvc-14.3 --build-type=complete toolset=msvc-14.3 address-model=64 architecture=x86 debug-symbols=on stage

If I remove line 116 of libs\python\src\object\enum.cpp I don't get the error.


          #if PY_VERSION_HEX < 0x03000000
              | Py_TPFLAGS_CHECKTYPES
          #endif
              | Py_TPFLAGS_HAVE_GC                    /* <============== remove this line */
              | Py_TPFLAGS_BASETYPE,                  /* tp_flags */

Is it safe to do this?

Dominant language
C++
Stars
537
Forks
223
Avg merge
11h 22m
Merged PRs (30d)
2

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from boostorg/python

All issues in boostorg/python

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.