]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] GH-141509: Fix warning about remaining subinterpreters (GH-141528) (GH-141566)
authorSergey Miryanov <sergey.miryanov@gmail.com>
Sat, 15 Nov 2025 18:56:52 +0000 (23:56 +0500)
committerGitHub <noreply@github.com>
Sat, 15 Nov 2025 18:56:52 +0000 (13:56 -0500)
(cherry picked from commit fa245df4a0848c15cf8d907c10fc92819994b866)

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Lib/test/test_interpreters/test_api.py
Misc/NEWS.d/next/Core_and_Builtins/2025-11-14-00-19-45.gh-issue-141528.VWdax1.rst [new file with mode: 0644]
Python/pylifecycle.c

index c5a1743e7fdedfb923f7994463c16d97df41780e..e88fd399dfba382ab88ba7eed3e3f5f447dded68 100644 (file)
@@ -431,6 +431,7 @@ class InterpreterObjectTests(TestBase):
         exit()"""
         stdout, stderr = repl.communicate(script)
         self.assertIsNone(stderr)
+        self.assertIn(b"Interpreter.close()", stdout)
         self.assertNotIn(b"Traceback", stdout)
 
 
diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2025-11-14-00-19-45.gh-issue-141528.VWdax1.rst b/Misc/NEWS.d/next/Core_and_Builtins/2025-11-14-00-19-45.gh-issue-141528.VWdax1.rst
new file mode 100644 (file)
index 0000000..a51aa49
--- /dev/null
@@ -0,0 +1,3 @@
+Suggest using :meth:`concurrent.interpreters.Interpreter.close` instead of the
+private ``_interpreters.destroy`` function when warning about remaining subinterpreters.
+Patch by Sergey Miryanov.
index 5b9ce617a48676dafea497c347a69baa421440e9..f5fbdeedac34ad1ea0f7c4b4e52b8d91917893b5 100644 (file)
@@ -2517,7 +2517,7 @@ finalize_subinterpreters(void)
     (void)PyErr_WarnEx(
             PyExc_RuntimeWarning,
             "remaining subinterpreters; "
-            "destroy them with _interpreters.destroy()",
+            "close them with Interpreter.close()",
             0);
 
     /* Swap out the current tstate, which we know must belong