# Bug report ### Bug description: Parent: https://github.com/python/cpython/issues/146102 https://gist.github.com/devdanzin/b022ff2d1304a4b2b8d3d8750abd8da5 # pylifecycle.c: Multiple init/fini cleanup bugs ## Summary 5 bugs in interpreter lifecycle: 1. **new_interpreter (line 2534)**: `return status` bypasses switch-back after `save_tstate` detach → thread state corruption. 2. **pycore_init_builtins (line 860)**: Direct `return` leaks `bimod` ref. 3. **add_main_module (line 2762)**: `bimod`/`loader` refs leaked on `PyDict_SetItemString` failure. 4. **finalize_clear_modules_dict (line 1685)**: Return value of `PyObject_CallMethodNoArgs` never DECREF'd. 5. **init_sys_streams (line 3019-3031)**: Unchecked `PySys_SetObject` for stdin/stdout (stderr correctly checked). ### CPython versions tested on: CPython main branch, 3.15 ### Operating systems tested on: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-149631 <!-- /gh-linked-prs -->
Activity