]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
GH-141509: Fix warning about remaining subinterpreters (GH-141528)
authorSergey Miryanov <sergey.miryanov@gmail.com>
Fri, 14 Nov 2025 14:55:04 +0000 (19:55 +0500)
committerGitHub <noreply@github.com>
Fri, 14 Nov 2025 14:55:04 +0000 (14:55 +0000)
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 9a5ee03e4722c0753a608d0e56cfca5cb8358a8e..fd9e46bf335fad25540a67ae6fbab2c3566a3af7 100644 (file)
@@ -432,7 +432,7 @@ class InterpreterObjectTests(TestBase):
         exit()"""
         stdout, stderr = repl.communicate(script)
         self.assertIsNone(stderr)
-        self.assertIn(b"remaining subinterpreters", stdout)
+        self.assertIn(b"Interpreter.close()", stdout)
         self.assertNotIn(b"Traceback", stdout)
 
     @support.requires_subprocess()
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 805805ef188e833008a1e7522ff6a0cbc3ce795b..67368b5ce077aab23d4629b50a64c70ceea7f640 100644 (file)
@@ -2643,7 +2643,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