diff options
author | xdegaye <xdegaye@gmail.com> | 2017-10-23 16:08:41 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-23 16:08:41 (GMT) |
commit | 66caacf2f0d6213b049a3097556e28e30440b900 (patch) | |
tree | 8485c0ccc79d52485f59529370bd71d30be798c6 /Lib | |
parent | 4ffd4653a7ec9c97775472276cf5e159e2366bb2 (diff) | |
download | cpython-66caacf2f0d6213b049a3097556e28e30440b900.zip cpython-66caacf2f0d6213b049a3097556e28e30440b900.tar.gz cpython-66caacf2f0d6213b049a3097556e28e30440b900.tar.bz2 |
bpo-30817: Fix PyErr_PrintEx() when no memory (#2526)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_exceptions.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py index ad4bc09..cef8d44 100644 --- a/Lib/test/test_exceptions.py +++ b/Lib/test/test_exceptions.py @@ -10,7 +10,7 @@ import errno from test.support import (TESTFN, captured_stderr, check_impl_detail, check_warnings, cpython_only, gc_collect, run_unittest, - no_tracing, unlink, import_module) + no_tracing, unlink, import_module, script_helper) class NaiveException(Exception): def __init__(self, x): @@ -1097,6 +1097,23 @@ class ExceptionTests(unittest.TestCase): self.assertIn("test message", report) self.assertTrue(report.endswith("\n")) + @cpython_only + def test_memory_error_in_PyErr_PrintEx(self): + code = """if 1: + import _testcapi + class C(): pass + _testcapi.set_nomemory(0, %d) + C() + """ + + # Issue #30817: Abort in PyErr_PrintEx() when no memory. + # Span a large range of tests as the CPython code always evolves with + # changes that add or remove memory allocations. + for i in range(1, 20): + rc, out, err = script_helper.assert_python_failure("-c", code % i) + self.assertIn(rc, (1, 120)) + self.assertIn(b'MemoryError', err) + def test_yield_in_nested_try_excepts(self): #Issue #25612 class MainError(Exception): |