https://github.com/python/cpython/commit/d3ada4509ea9f4d5c7a7a28566049c8891ee6d11
commit: d3ada4509ea9f4d5c7a7a28566049c8891ee6d11
branch: main
author: Victor Stinner <[email protected]>
committer: vstinner <[email protected]>
date: 2026-10-16T17:43:30+02:00
summary:
gh-157242: Use support.inject_memory_error_cm() in test_dict (#159543)
files:
M Lib/test/test_dict.py
diff --git a/Lib/test/test_dict.py b/Lib/test/test_dict.py
index 9d013e3d2caa1c..9b1f8d5b8db394 100644
--- a/Lib/test/test_dict.py
+++ b/Lib/test/test_dict.py
@@ -121,18 +121,16 @@ def test_item_iterator_oom(self):
import_helper.import_module('_testcapi')
from test.support.script_helper import assert_python_ok
code = """if 1:
- import _testcapi
+ from test import support
items = {1: 2, 3: 4}.items()
ballast = [(i, i) for i in range(3000)]
held = []
for start in range(1, 5):
- _testcapi.set_nomemory(start)
try:
- held.append(iter(items))
+ with support.inject_memory_error_cm(start):
+ held.append(iter(items))
except MemoryError:
pass
- finally:
- _testcapi.remove_mem_hooks()
"""
assert_python_ok('-c', code)
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]