[3.14] gh-135729: Store reference to globals in Interpreter._decref (GH-139104) (GH-139112)

* gh-135729: Store reference to globals in `Interpreter._decref` (GH-139104)
(cherry picked from commit 571210b8f3)

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
This commit is contained in:
Miss Islington (bot) 2025-10-07 20:18:15 +02:00 committed by GitHub
parent 5b64b59618
commit 070993b8ad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 24 additions and 2 deletions

View file

@ -419,6 +419,21 @@ def test_pickle(self):
unpickled = pickle.loads(data)
self.assertEqual(unpickled, interp)
@support.requires_subprocess()
@force_not_colorized
def test_cleanup_in_repl(self):
# GH-135729: Using a subinterpreter in the REPL would lead to an unraisable
# exception during finalization
repl = script_helper.spawn_python("-i")
script = b"""if True:
from concurrent import interpreters
interpreters.create()
exit()"""
stdout, stderr = repl.communicate(script)
self.assertIsNone(stderr)
self.assertNotIn(b"Traceback", stdout)
class TestInterpreterIsRunning(TestBase):