File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1175,9 +1175,12 @@ make_new_set_basetype(PyTypeObject *type, PyObject *iterable)
11751175}
11761176
11771177void
1178+ // gh-140232: check whether a frozenset can be untracked from the GC
11781179_PyFrozenSet_MaybeUntrack (PyObject * op )
11791180{
1180- if (op == NULL || !PyFrozenSet_CheckExact (op )) {
1181+ assert (op != NULL );
1182+ // subclasses of a frozenset can generate reference cycles, so do not untrack
1183+ if (!PyFrozenSet_CheckExact (op )) {
11811184 return ;
11821185 }
11831186 // if no elements of a frozenset are tracked by the GC, we untrack the object
@@ -2732,7 +2735,9 @@ PyObject *
27322735PyFrozenSet_New (PyObject * iterable )
27332736{
27342737 PyObject * result = make_new_set (& PyFrozenSet_Type , iterable );
2735- _PyFrozenSet_MaybeUntrack (result );
2738+ if (result != 0 ) {
2739+ _PyFrozenSet_MaybeUntrack (result );
2740+ }
27362741 return result ;
27372742}
27382743
You can’t perform that action at this time.
0 commit comments