From 2a28b21a517775120a7a720adc29cf85111e8bf4 Mon Sep 17 00:00:00 2001 From: Eric Snow Date: Fri, 25 Apr 2025 10:43:50 -0600 Subject: gh-132776: Revert Moving memoryview XIData Code to memoryobject.c (gh-132960) This is a partial revert of gh-132821. It resolves the refleak introduced by that PR. --- Python/crossinterp.c | 38 ++++---------------------------------- 1 file changed, 4 insertions(+), 34 deletions(-) (limited to 'Python/crossinterp.c') diff --git a/Python/crossinterp.c b/Python/crossinterp.c index 7a19cc3da1f..094bbbe54f2 100644 --- a/Python/crossinterp.c +++ b/Python/crossinterp.c @@ -1902,25 +1902,7 @@ _PyXI_Fini(PyInterpreterState *interp) PyStatus _PyXI_InitTypes(PyInterpreterState *interp) { - if (_Py_IsMainInterpreter(interp)) { - _PyXI_global_state_t *global_state = _PyXI_GET_GLOBAL_STATE(interp); - if (global_state == NULL) { - PyErr_PrintEx(0); - return _PyStatus_ERR( - "failed to get global cross-interpreter state"); - } - xid_lookup_init(&global_state->data_lookup); - } - - _PyXI_state_t *state = _PyXI_GET_STATE(interp); - if (state == NULL) { - PyErr_PrintEx(0); - return _PyStatus_ERR( - "failed to get interpreter's cross-interpreter state"); - } - xid_lookup_init(&state->data_lookup); - - if (init_static_exctypes(&state->exceptions, interp) < 0) { + if (init_static_exctypes(&_PyXI_GET_STATE(interp)->exceptions, interp) < 0) { PyErr_PrintEx(0); return _PyStatus_ERR( "failed to initialize the cross-interpreter exception types"); @@ -1933,21 +1915,9 @@ _PyXI_InitTypes(PyInterpreterState *interp) void _PyXI_FiniTypes(PyInterpreterState *interp) { - _PyXI_state_t *state = _PyXI_GET_STATE(interp); - if (state != NULL) { - // We would finalize heap types here too but that leads to ref leaks. - // Instead, we finalize them in _PyXI_Fini(). - fini_static_exctypes(&state->exceptions, interp); - - xid_lookup_fini(&state->data_lookup); - } - - if (_Py_IsMainInterpreter(interp)) { - _PyXI_global_state_t *global_state = _PyXI_GET_GLOBAL_STATE(interp); - if (global_state != NULL) { - xid_lookup_fini(&global_state->data_lookup); - } - } + // We would finalize heap types here too but that leads to ref leaks. + // Instead, we finalize them in _PyXI_Fini(). + fini_static_exctypes(&_PyXI_GET_STATE(interp)->exceptions, interp); } -- cgit v1.2.3