Skip to content

Commit cdd6a58

Browse files
committed
Fix Py_GenericAliasIterType to be finalized at exit.
1 parent 4d2403f commit cdd6a58

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#ifndef Py_INTERNAL_GENERICALIASOBJECT_H
2+
#define Py_INTERNAL_GENERICALIASOBJECT_H
3+
#ifdef __cplusplus
4+
extern "C" {
5+
#endif
6+
7+
#ifndef Py_BUILD_CORE
8+
# error "this header requires Py_BUILD_CORE define"
9+
#endif
10+
11+
extern PyTypeObject _Py_GenericAliasIterType;
12+
13+
#ifdef __cplusplus
14+
}
15+
#endif
16+
#endif /* !Py_INTERNAL_GENERICALIASOBJECT_H */
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix :class:`generic_alias_iterator` to be finalized at exit.

Objects/genericaliasobject.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ ga_iter_clear(PyObject *self) {
683683
return 0;
684684
}
685685

686-
static PyTypeObject Py_GenericAliasIterType = {
686+
PyTypeObject _Py_GenericAliasIterType = {
687687
PyVarObject_HEAD_INIT(&PyType_Type, 0)
688688
.tp_name = "generic_alias_iterator",
689689
.tp_basicsize = sizeof(gaiterobject),
@@ -697,7 +697,7 @@ static PyTypeObject Py_GenericAliasIterType = {
697697

698698
static PyObject *
699699
ga_iter(PyObject *self) {
700-
gaiterobject *gi = PyObject_GC_New(gaiterobject, &Py_GenericAliasIterType);
700+
gaiterobject *gi = PyObject_GC_New(gaiterobject, &_Py_GenericAliasIterType);
701701
if (gi == NULL) {
702702
return NULL;
703703
}

Objects/object.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "pycore_unionobject.h" // _PyUnion_Type
1919
#include "frameobject.h" // PyFrame_Type
2020
#include "pycore_interpreteridobject.h" // _PyInterpreterID_Type
21+
#include "pycore_genericaliasobject.h" // _Py_GenericAliasIterType
2122

2223
#ifdef Py_LIMITED_API
2324
// Prevent recursive call _Py_IncRef() <=> Py_INCREF()
@@ -1923,6 +1924,7 @@ static PyTypeObject* static_types[] = {
19231924
&_PyAsyncGenWrappedValue_Type,
19241925
&_PyContextTokenMissing_Type,
19251926
&_PyCoroWrapper_Type,
1927+
&_Py_GenericAliasIterType,
19261928
&_PyHamtItems_Type,
19271929
&_PyHamtKeys_Type,
19281930
&_PyHamtValues_Type,

0 commit comments

Comments
 (0)