Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Small cleanup.
  • Loading branch information
ericsnowcurrently committed Jun 17, 2024
commit bbfafd8aaf05b1e2f7d61e06c151450edc6c5b7d
34 changes: 20 additions & 14 deletions Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ type_from_ref(PyObject *ref)
}


/* helpers for for static builtin types */
/* helpers for for managed static types */

#ifndef NDEBUG
static inline int
Expand Down Expand Up @@ -389,6 +389,24 @@ managed_static_type_state_clear(PyInterpreterState *interp, PyTypeObject *self,
}
}

static void
managed_static_types_fini(PyInterpreterState *interp)
{
assert(interp->types.managed_static.num_types == 0);
// All the managed static types should have been finalized already.
for (size_t i = 0; i < _Py_MAX_MANAGED_STATIC_TYPES; i++) {
assert(interp->types.managed_static.types[i].type == NULL);
}
if (_Py_IsMainInterpreter(interp)) {
assert(_PyRuntime.types.managed_static.num_types == 0);
// All the managed static types should have been finalized already.
for (size_t i = 0; i < _Py_MAX_MANAGED_STATIC_TYPES; i++) {
assert(_PyRuntime.types.managed_static.types[i].type == NULL);
assert(_PyRuntime.types.managed_static.types[i].interp_count == 0);
}
}
}

// Also see _PyStaticType_InitBuiltin() and _PyStaticType_FiniBuiltin().

/* end static builtin helpers */
Expand Down Expand Up @@ -946,19 +964,7 @@ _PyTypes_Fini(PyInterpreterState *interp)
struct type_cache *cache = &interp->types.type_cache;
type_cache_clear(cache, NULL);

assert(interp->types.managed_static.num_types == 0);
// All the managed static types should have been finalized already.
for (size_t i = 0; i < _Py_MAX_MANAGED_STATIC_TYPES; i++) {
assert(interp->types.managed_static.types[i].type == NULL);
}
if (_Py_IsMainInterpreter(interp)) {
assert(_PyRuntime.types.managed_static.num_types == 0);
// All the managed static types should have been finalized already.
for (size_t i = 0; i < _Py_MAX_MANAGED_STATIC_TYPES; i++) {
assert(_PyRuntime.types.managed_static.types[i].type == NULL);
assert(_PyRuntime.types.managed_static.types[i].interp_count == 0);
}
}
managed_static_types_fini(interp);
}


Expand Down