[3.14] GH-141509: Fix warning about remaining subinterpreters (GH-141528) (GH-141566)

(cherry picked from commit fa245df4a0)

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
This commit is contained in:
Sergey Miryanov 2025-11-15 23:56:52 +05:00 committed by GitHub
parent 8a67e3c2b0
commit 21e43d5e83
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 5 additions and 1 deletions

View 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)

View file

@ -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.

View 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