← 返回首页
bpo-32604: Fix memory leaks in the new _xxsubinterpreters module. by ericsnowcurrently · Pull Request #5507 · python/cpython · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (2) .py  (1) All 2 file types selected Viewed files
Conversations
Failed to load comments. Retry
Loading
Jump to
Jump to file
Failed to load files. Retry
Loading
Diff view
Unified
Split
Hide whitespace
Apply and reload
Show whitespace
Diff view
Unified
Split
Hide whitespace
Apply and reload
18 changes: 10 additions & 8 deletions Lib/test/test__xxsubinterpreters.py
Show comments View file Edit file Delete file Open in desktop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -362,13 +362,15 @@ def test_bad_id(self):
def test_from_current(self):
main, = interpreters.list_all()
id = interpreters.create()
script = dedent("""
script = dedent(f"""
import _xxsubinterpreters as _interpreters
_interpreters.destroy({})
""").format(id)
try:
_interpreters.destroy({id})
except RuntimeError:
pass
""")

with self.assertRaises(RuntimeError):
interpreters.run_string(id, script)
interpreters.run_string(id, script)
self.assertEqual(set(interpreters.list_all()), {main, id})

def test_from_sibling(self):
Expand Down Expand Up @@ -761,12 +763,12 @@ def __int__(self):
self.assertEqual(int(cid), 10)

def test_bad_id(self):
ids = [-1, 2**64, "spam"]
for cid in ids:
for cid in [-1, 'spam']:
with self.subTest(cid):
with self.assertRaises(ValueError):
interpreters._channel_id(cid)

with self.assertRaises(OverflowError):
interpreters._channel_id(2**64)
with self.assertRaises(TypeError):
interpreters._channel_id(object())

Expand Down
Loading
Toggle all file notes Toggle all file annotations

Footer

© 2026 GitHub, Inc.