Thomas W Rodgers efa25cf
From ae5da2a7e8f1111757d8a474095486a5b22aa12d Mon Sep 17 00:00:00 2001
Thomas W Rodgers efa25cf
From: Victor Stinner <vstinner@python.org>
Thomas W Rodgers efa25cf
Date: Mon, 25 Apr 2022 10:51:46 +0200
Thomas W Rodgers efa25cf
Subject: [PATCH] Fix enum_type_object type on Python 3.11
Thomas W Rodgers efa25cf
Thomas W Rodgers efa25cf
The enum_type_object type inherits from PyLong_Type which is not tracked
Thomas W Rodgers efa25cf
by the GC. Instances doesn't have to be tracked by the GC: remove the
Thomas W Rodgers efa25cf
Py_TPFLAGS_HAVE_GC flag.
Thomas W Rodgers efa25cf
Thomas W Rodgers efa25cf
The Python C API documentation says:
Thomas W Rodgers efa25cf
Thomas W Rodgers efa25cf
    "To create a container type, the tp_flags field of the type object
Thomas W Rodgers efa25cf
    must include the Py_TPFLAGS_HAVE_GC and provide an implementation of
Thomas W Rodgers efa25cf
    the tp_traverse handler."
Thomas W Rodgers efa25cf
Thomas W Rodgers efa25cf
https://docs.python.org/dev/c-api/gcsupport.html
Thomas W Rodgers efa25cf
Thomas W Rodgers efa25cf
The new exception was introduced in Python 3.11 by:
Thomas W Rodgers efa25cf
https://github.com/python/cpython/issues/88429
Thomas W Rodgers efa25cf
---
Thomas W Rodgers efa25cf
 libs/python/src/object/enum.cpp | 1 -
Thomas W Rodgers efa25cf
 1 file changed, 1 deletion(-)
Thomas W Rodgers efa25cf
Thomas W Rodgers efa25cf
diff --git a/libs/python/src/object/enum.cpp b/libs/python/src/object/enum.cpp
Thomas W Rodgers efa25cf
index 293e705899..5753b32e07 100644
Thomas W Rodgers efa25cf
--- a/libs/python/src/object/enum.cpp
Thomas W Rodgers efa25cf
+++ b/libs/python/src/object/enum.cpp
Thomas W Rodgers efa25cf
@@ -113,7 +113,6 @@ static PyTypeObject enum_type_object = {
Thomas W Rodgers efa25cf
 #if PY_VERSION_HEX < 0x03000000
Thomas W Rodgers efa25cf
     | Py_TPFLAGS_CHECKTYPES
Thomas W Rodgers efa25cf
 #endif
Thomas W Rodgers efa25cf
-    | Py_TPFLAGS_HAVE_GC
Thomas W Rodgers efa25cf
     | Py_TPFLAGS_BASETYPE,                  /* tp_flags */
Thomas W Rodgers efa25cf
     0,                                      /* tp_doc */
Thomas W Rodgers efa25cf
     0,                                      /* tp_traverse */