From 48c3e2c36ec7a57d26fa515a0a9ec46756f778b7 Mon Sep 17 00:00:00 2001 From: Sergey Miryanov Date: Thu, 13 Nov 2025 23:31:46 +0500 Subject: [PATCH 1/7] Fix warning about remaining subinterpreters --- Python/pylifecycle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index 805805ef188e83..67368b5ce077aa 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -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 From 9930dac9a3735b49268b3fe77fe2e9c3a021158c Mon Sep 17 00:00:00 2001 From: Sergey Miryanov Date: Fri, 14 Nov 2025 00:20:04 +0500 Subject: [PATCH 2/7] Update tests and add news --- Lib/test/test_interpreters/test_api.py | 3 ++- .../2025-11-14-00-19-45.gh-issue-141528.VWdax1.rst | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Core_and_Builtins/2025-11-14-00-19-45.gh-issue-141528.VWdax1.rst diff --git a/Lib/test/test_interpreters/test_api.py b/Lib/test/test_interpreters/test_api.py index 9a5ee03e4722c0..ccc1d808413ce7 100644 --- a/Lib/test/test_interpreters/test_api.py +++ b/Lib/test/test_interpreters/test_api.py @@ -432,7 +432,8 @@ def test_cleanup_in_repl(self): exit()""" stdout, stderr = repl.communicate(script) self.assertIsNone(stderr) - self.assertIn(b"remaining subinterpreters", stdout) + msg = b"remaining subinterpreters; close them with Interpreter.close()" + self.assertIn(msg, 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 index 00000000000000..214274f0a547f0 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2025-11-14-00-19-45.gh-issue-141528.VWdax1.rst @@ -0,0 +1,4 @@ +Fix warning message about remaining :mod:`subinterpreters +` while finalizing :mod:`"main" interpreter +` and suggest using of :method:`Interpreter.close`. +Patch by Sergey Miryanov. From 5ba5863c2cca2661157799ad2f586c9b357009ab Mon Sep 17 00:00:00 2001 From: Sergey Miryanov Date: Fri, 14 Nov 2025 00:28:29 +0500 Subject: [PATCH 3/7] Fix news --- .../2025-11-14-00-19-45.gh-issue-141528.VWdax1.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 214274f0a547f0..d1d8f6f4425bff 100644 --- 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 @@ -1,4 +1,4 @@ Fix warning message about remaining :mod:`subinterpreters ` while finalizing :mod:`"main" interpreter -` and suggest using of :method:`Interpreter.close`. +` and suggest using of :meth:`Interpreter.close`. Patch by Sergey Miryanov. From 128c63a18d1700733f6335d988a1fffbc94df1bc Mon Sep 17 00:00:00 2001 From: Sergey Miryanov Date: Fri, 14 Nov 2025 00:36:52 +0500 Subject: [PATCH 4/7] Fix news --- .../2025-11-14-00-19-45.gh-issue-141528.VWdax1.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index d1d8f6f4425bff..3aac6841e6c610 100644 --- 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 @@ -1,4 +1,4 @@ Fix warning message about remaining :mod:`subinterpreters ` while finalizing :mod:`"main" interpreter -` and suggest using of :meth:`Interpreter.close`. +` and suggest using of ``Interpreter.close``. Patch by Sergey Miryanov. From 4df921d7025ea4f61d83af752afbd4ba9e1accf5 Mon Sep 17 00:00:00 2001 From: Sergey Miryanov Date: Fri, 14 Nov 2025 10:15:56 +0500 Subject: [PATCH 5/7] Update Misc/NEWS.d/next/Core_and_Builtins/2025-11-14-00-19-45.gh-issue-141528.VWdax1.rst Co-authored-by: Peter Bierma --- .../2025-11-14-00-19-45.gh-issue-141528.VWdax1.rst | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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 index 3aac6841e6c610..a1ffb096c72c3f 100644 --- 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 @@ -1,4 +1,2 @@ -Fix warning message about remaining :mod:`subinterpreters -` while finalizing :mod:`"main" interpreter -` and suggest using of ``Interpreter.close``. +Suggest using :meth:`concurrent.interpreters.Interpreter.close` instead of the private `_interpreters.close` function when warning about remaining subinterpreters. Patch by Sergey Miryanov. From 8eae3198b53de9878252e1b018b306d316253fa3 Mon Sep 17 00:00:00 2001 From: Sergey Miryanov Date: Fri, 14 Nov 2025 10:18:25 +0500 Subject: [PATCH 6/7] Fix test and news --- Lib/test/test_interpreters/test_api.py | 3 +-- .../2025-11-14-00-19-45.gh-issue-141528.VWdax1.rst | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_interpreters/test_api.py b/Lib/test/test_interpreters/test_api.py index ccc1d808413ce7..fd9e46bf335fad 100644 --- a/Lib/test/test_interpreters/test_api.py +++ b/Lib/test/test_interpreters/test_api.py @@ -432,8 +432,7 @@ def test_cleanup_in_repl(self): exit()""" stdout, stderr = repl.communicate(script) self.assertIsNone(stderr) - msg = b"remaining subinterpreters; close them with Interpreter.close()" - self.assertIn(msg, 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 index a1ffb096c72c3f..60db2a61417581 100644 --- 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 @@ -1,2 +1,3 @@ -Suggest using :meth:`concurrent.interpreters.Interpreter.close` instead of the private `_interpreters.close` function when warning about remaining subinterpreters. +Suggest using :meth:`concurrent.interpreters.Interpreter.close` instead of the +private `_interpreters.destroy` function when warning about remaining subinterpreters. Patch by Sergey Miryanov. From 4ebcfaff9f35292cbe91c9e45de8756f573881a0 Mon Sep 17 00:00:00 2001 From: Sergey Miryanov Date: Fri, 14 Nov 2025 10:30:53 +0500 Subject: [PATCH 7/7] Fix news --- .../2025-11-14-00-19-45.gh-issue-141528.VWdax1.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 60db2a61417581..a51aa49522866b 100644 --- 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 @@ -1,3 +1,3 @@ Suggest using :meth:`concurrent.interpreters.Interpreter.close` instead of the -private `_interpreters.destroy` function when warning about remaining subinterpreters. +private ``_interpreters.destroy`` function when warning about remaining subinterpreters. Patch by Sergey Miryanov.