Skip to content

Commit 4e9da0d

Browse files
bpo-32604: Fix memory leaks in the new _xxsubinterpreters module. (#5507)
1 parent 2f79c01 commit 4e9da0d

File tree

3 files changed

+607
-276
lines changed

3 files changed

+607
-276
lines changed

Lib/test/test__xxsubinterpreters.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -362,13 +362,15 @@ def test_bad_id(self):
362362
def test_from_current(self):
363363
main, = interpreters.list_all()
364364
id = interpreters.create()
365-
script = dedent("""
365+
script = dedent(f"""
366366
import _xxsubinterpreters as _interpreters
367-
_interpreters.destroy({})
368-
""").format(id)
367+
try:
368+
_interpreters.destroy({id})
369+
except RuntimeError:
370+
pass
371+
""")
369372

370-
with self.assertRaises(RuntimeError):
371-
interpreters.run_string(id, script)
373+
interpreters.run_string(id, script)
372374
self.assertEqual(set(interpreters.list_all()), {main, id})
373375

374376
def test_from_sibling(self):
@@ -761,12 +763,12 @@ def __int__(self):
761763
self.assertEqual(int(cid), 10)
762764

763765
def test_bad_id(self):
764-
ids = [-1, 2**64, "spam"]
765-
for cid in ids:
766+
for cid in [-1, 'spam']:
766767
with self.subTest(cid):
767768
with self.assertRaises(ValueError):
768769
interpreters._channel_id(cid)
769-
770+
with self.assertRaises(OverflowError):
771+
interpreters._channel_id(2**64)
770772
with self.assertRaises(TypeError):
771773
interpreters._channel_id(object())
772774

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy