Repository navigation
Fix enum_type_object type on Python 3.11 - #385
Conversation
The enum_type_object type inherits from PyLong_Type which is not tracked
by the GC. Instances doesn't have to be tracked by the GC: remove the
Py_TPFLAGS_HAVE_GC flag.
The Python C API documentation says:
"To create a container type, the tp_flags field of the type object
must include the Py_TPFLAGS_HAVE_GC and provide an implementation of
the tp_traverse handler."
https://docs.python.org/dev/c-api/gcsupport.html
The new exception was introduced in Python 3.11 by:
python/cpython#88429
|
A Boost Python enum also has a name, but a name type is a Python str string which is not tracked by the GC. Example (in Python 3.11): >>> import gc
>>> my_str="hello"
>>> gc.is_tracked(my_str)
FalseSo it's fine to no track Boost Python enums by the Python GC. Only objects which contain other objects must be tracked by the GC, like containers (list, dict, ...). Reference documentation about the Python GC: https://devguide.python.org/garbage_collector/ |
|
The "deploy documentation / deploy (pull_request)" CI job failed with: It doesn't seem to be related to my change. |
It seems to be unrelated to my change:
|
|
imath test suite pass with this change, it has been tested in a Fedora COPR for Python 3.11 with this change, and imath package built successfully: https://copr.fedorainfracloud.org/coprs/g/python/python3.11/builds/
Without this change, imath raises a SystemError "type Boost.Python.enum has the Py_TPFLAGS_HAVE_GC flag but has no traverse function" on Python 3.11: AcademySoftwareFoundation/Imath#253 Fedora issues about Boost Python on Python 3.11: |
|
Thanks @vstinner for this PR. I confirm that the CI build failure is unrelated (and is in fact a misconfiguration in the CI workflow logic, as PRs from other repos lack permission to push doc updates). |
Related to conda-forge#155 Patch commit from boostorg/python#385
Related to conda-forge#155 Patch commit from boostorg/python#385
The import checks didn't pass because of a boost binding problem solved by boostorg/python#385.
The enum_type_object type inherits from PyLong_Type which is not tracked
by the GC. Instances doesn't have to be tracked by the GC: remove the
Py_TPFLAGS_HAVE_GC flag.
The Python C API documentation says:
https://docs.python.org/dev/c-api/gcsupport.html
The new exception was introduced in Python 3.11 by:
python/cpython#88429