https://github.com/python/cpython/commit/c6cc28299e7ea4944ed4b4c348377a055c747b71 commit: c6cc28299e7ea4944ed4b4c348377a055c747b71 branch: 3.14 author: Miss Islington (bot) <31488909+miss-isling...@users.noreply.github.com> committer: ericsnowcurrently <ericsnowcurren...@gmail.com> date: 2025-05-26T13:14:58-06:00 summary:
[3.14] gh-134557: Suppress immortalization in _PyCode_GetScriptXIData under free-threading (gh134738) Disable immortalization around Py_CompileString*(). The same approach as 332356b that fixed the refleaks in compile() and eval(). E: 09e72cf can pass test_capi, test_sys and test__interpchannels with this patch for me. (cherry picked from commit c60f39ada625562bff26400f304690c19fe9f504, AKA gh-134686) Co-authored-by: neonene <53406459+neon...@users.noreply.github.com> files: M Python/crossinterp.c diff --git a/Python/crossinterp.c b/Python/crossinterp.c index 26eecdddf4bdd0..13d91c508c41fa 100644 --- a/Python/crossinterp.c +++ b/Python/crossinterp.c @@ -908,8 +908,15 @@ get_script_xidata(PyThreadState *tstate, PyObject *obj, int pure, } goto error; } +#ifdef Py_GIL_DISABLED + // Don't immortalize code constants to avoid memory leaks. + ((_PyThreadStateImpl *)tstate)->suppress_co_const_immortalization++; +#endif code = Py_CompileStringExFlags( script, filename, Py_file_input, &cf, optimize); +#ifdef Py_GIL_DISABLED + ((_PyThreadStateImpl *)tstate)->suppress_co_const_immortalization--; +#endif Py_XDECREF(ref); if (code == NULL) { goto error; _______________________________________________ Python-checkins mailing list -- python-checkins@python.org To unsubscribe send an email to python-checkins-le...@python.org https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: arch...@mail-archive.com