diff options
author | Victor Stinner <vstinner@redhat.com> | 2019-09-17 23:35:33 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-17 23:35:33 (GMT) |
commit | 1ce16fb0977283ae42a9f8917bbca5f44aa69324 (patch) | |
tree | fdb8005d57223998984d9a20cc171f25ec94ea12 /Lib/test/test_faulthandler.py | |
parent | d3b904144e86e2442961de6a7dccecbe133d5c6d (diff) | |
download | cpython-1ce16fb0977283ae42a9f8917bbca5f44aa69324.zip cpython-1ce16fb0977283ae42a9f8917bbca5f44aa69324.tar.gz cpython-1ce16fb0977283ae42a9f8917bbca5f44aa69324.tar.bz2 |
bpo-38070: Py_FatalError() logs runtime state (GH-16246)
Diffstat (limited to 'Lib/test/test_faulthandler.py')
-rw-r--r-- | Lib/test/test_faulthandler.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/Lib/test/test_faulthandler.py b/Lib/test/test_faulthandler.py index b1aa8c3..2448744 100644 --- a/Lib/test/test_faulthandler.py +++ b/Lib/test/test_faulthandler.py @@ -90,7 +90,8 @@ class FaultHandlerTests(unittest.TestCase): def check_error(self, code, line_number, fatal_error, *, filename=None, all_threads=True, other_regex=None, - fd=None, know_current_thread=True): + fd=None, know_current_thread=True, + py_fatal_error=False): """ Check that the fault handler for fatal errors is enabled and check the traceback from the child process output. @@ -110,10 +111,12 @@ class FaultHandlerTests(unittest.TestCase): {header} \(most recent call first\): File "<string>", line {lineno} in <module> """ - regex = dedent(regex.format( + if py_fatal_error: + fatal_error += "\nPython runtime state: initialized" + regex = dedent(regex).format( lineno=line_number, fatal_error=fatal_error, - header=header)).strip() + header=header).strip() if other_regex: regex += '|' + other_regex output, exitcode = self.get_output(code, filename=filename, fd=fd) @@ -170,7 +173,8 @@ class FaultHandlerTests(unittest.TestCase): """, 3, 'in new thread', - know_current_thread=False) + know_current_thread=False, + py_fatal_error=True) def test_sigabrt(self): self.check_fatal_error(""" @@ -226,7 +230,8 @@ class FaultHandlerTests(unittest.TestCase): faulthandler._fatal_error(b'xyz') """, 2, - 'xyz') + 'xyz', + py_fatal_error=True) def test_fatal_error_without_gil(self): self.check_fatal_error(""" @@ -234,7 +239,8 @@ class FaultHandlerTests(unittest.TestCase): faulthandler._fatal_error(b'xyz', True) """, 2, - 'xyz') + 'xyz', + py_fatal_error=True) @unittest.skipIf(sys.platform.startswith('openbsd'), "Issue #12868: sigaltstack() doesn't work on " |