Skip to content
Prev Previous commit
Drop the finalization code.
  • Loading branch information
ericsnowcurrently committed Jul 11, 2024
commit ebda6371293dbe18649948118cc2e5fa5c926e9a
22 changes: 2 additions & 20 deletions Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,15 +269,14 @@ managed_static_type_state_init(PyInterpreterState *interp, PyTypeObject *self,

/* Reset the type's per-interpreter state.
This basically undoes what managed_static_type_state_init() did. */
static PyTypeObject *
static void
managed_static_type_state_clear(PyInterpreterState *interp, PyTypeObject *self,
int isbuiltin, int final)
{
size_t index = managed_static_type_index_get(self);
size_t full_index = isbuiltin
? index
: index + _Py_MAX_MANAGED_STATIC_BUILTIN_TYPES;
PyTypeObject *def = &_PyRuntime.types.managed_static.types[full_index].def;

managed_static_type_state *state = isbuiltin
? &(interp->types.builtins.initialized[index])
Expand Down Expand Up @@ -313,8 +312,6 @@ managed_static_type_state_clear(PyInterpreterState *interp, PyTypeObject *self,
}
PyMutex_Unlock(&interp->types.mutex);
}

return def;
}

static PyTypeObject *
Expand Down Expand Up @@ -5852,15 +5849,7 @@ fini_static_type(PyInterpreterState *interp, PyTypeObject *type,
}

_PyStaticType_ClearWeakRefs(interp, type);
PyTypeObject *def =
managed_static_type_state_clear(interp, type, isbuiltin, final);
/* For now we exclude extension module types. */
if (final && isbuiltin) {
/* Restore the static type to it's (mostly) original values. */
destructor dealloc = type->tp_dealloc;
memcpy(type, def, sizeof(PyTypeObject));
type->tp_dealloc = dealloc;
}
managed_static_type_state_clear(interp, type, isbuiltin, final);
}

void
Expand Down Expand Up @@ -8492,9 +8481,6 @@ init_static_type(PyInterpreterState *interp, PyTypeObject *self,
PyTypeObject *def = managed_static_type_get_def(self, isbuiltin);
if (initial) {
memcpy(def, self, sizeof(PyTypeObject));
/* For now we do not worry about preserving the index
at finalization. */
managed_static_type_index_clear(def);
}

int res;
Expand All @@ -8506,10 +8492,6 @@ init_static_type(PyInterpreterState *interp, PyTypeObject *self,
managed_static_type_state_clear(interp, self, isbuiltin, initial);
}

if (initial) {
Py_SET_TYPE(def, Py_TYPE(self));
}

return res;
}

Expand Down