diff options
Diffstat (limited to 'Python/context.c')
-rw-r--r-- | Python/context.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Python/context.c b/Python/context.c index 3cf8db4..dedbca9 100644 --- a/Python/context.c +++ b/Python/context.c @@ -335,6 +335,10 @@ _context_alloc(void) PyInterpreterState *interp = _PyInterpreterState_GET(); struct _Py_context_state *state = &interp->context; PyContext *ctx; +#ifdef Py_DEBUG + // _context_alloc() must not be called after _PyContext_Fini() + assert(state->numfree != -1); +#endif if (state->numfree) { state->numfree--; ctx = state->freelist; @@ -460,6 +464,10 @@ context_tp_dealloc(PyContext *self) PyInterpreterState *interp = _PyInterpreterState_GET(); struct _Py_context_state *state = &interp->context; +#ifdef Py_DEBUG + // _context_alloc() must not be called after _PyContext_Fini() + assert(state->numfree != -1); +#endif if (state->numfree < CONTEXT_FREELIST_MAXLEN) { state->numfree++; self->ctx_weakreflist = (PyObject *)state->freelist; @@ -1290,6 +1298,10 @@ _PyContext_Fini(PyThreadState *tstate) { Py_CLEAR(_token_missing); _PyContext_ClearFreeList(tstate); +#ifdef Py_DEBUG + struct _Py_context_state *state = &tstate->interp->context; + state->numfree = -1; +#endif _PyHamt_Fini(); } |