summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_capi.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-03-06 23:54:20 (GMT)
committerGitHub <noreply@github.com>2020-03-06 23:54:20 (GMT)
commit9e5d30cc99e34f4c3e7b2cd851de20816c9d1927 (patch)
tree71e726c4695b9b3b0a31d7d2516ce8ee83b52721 /Lib/test/test_capi.py
parent7b3c252dc7f44d4bdc4c7c82d225ebd09c78f520 (diff)
downloadcpython-9e5d30cc99e34f4c3e7b2cd851de20816c9d1927.zip
cpython-9e5d30cc99e34f4c3e7b2cd851de20816c9d1927.tar.gz
cpython-9e5d30cc99e34f4c3e7b2cd851de20816c9d1927.tar.bz2
bpo-39882: Py_FatalError() logs the function name (GH-18819)
The Py_FatalError() function is replaced with a macro which logs automatically the name of the current function, unless the Py_LIMITED_API macro is defined. Changes: * Add _Py_FatalErrorFunc() function. * Remove the function name from the message of Py_FatalError() calls which included the function name. * Update tests.
Diffstat (limited to 'Lib/test/test_capi.py')
-rw-r--r--Lib/test/test_capi.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py
index e65973c..ff18a21 100644
--- a/Lib/test/test_capi.py
+++ b/Lib/test/test_capi.py
@@ -61,8 +61,8 @@ class CAPITest(unittest.TestCase):
self.assertEqual(out, b'')
# This used to cause an infinite loop.
self.assertTrue(err.rstrip().startswith(
- b'Fatal Python error:'
- b' PyThreadState_Get: no current thread'))
+ b'Fatal Python error: '
+ b'PyThreadState_Get: no current thread'))
def test_memoryview_from_NULL_pointer(self):
self.assertRaises(ValueError, _testcapi.make_memoryview_from_NULL_pointer)
@@ -197,7 +197,8 @@ class CAPITest(unittest.TestCase):
""")
rc, out, err = assert_python_failure('-c', code)
self.assertRegex(err.replace(b'\r', b''),
- br'Fatal Python error: a function returned NULL '
+ br'Fatal Python error: _Py_CheckFunctionResult: '
+ br'a function returned NULL '
br'without setting an error\n'
br'Python runtime state: initialized\n'
br'SystemError: <built-in function '
@@ -225,8 +226,9 @@ class CAPITest(unittest.TestCase):
""")
rc, out, err = assert_python_failure('-c', code)
self.assertRegex(err.replace(b'\r', b''),
- br'Fatal Python error: a function returned a '
- br'result with an error set\n'
+ br'Fatal Python error: _Py_CheckFunctionResult: '
+ br'a function returned a result '
+ br'with an error set\n'
br'Python runtime state: initialized\n'
br'ValueError\n'
br'\n'
@@ -668,7 +670,7 @@ class PyMemDebugTests(unittest.TestCase):
r"\n"
r"Enable tracemalloc to get the memory block allocation traceback\n"
r"\n"
- r"Fatal Python error: bad trailing pad byte")
+ r"Fatal Python error: _PyMem_DebugRawFree: bad trailing pad byte")
regex = regex.format(ptr=self.PTR_REGEX)
regex = re.compile(regex, flags=re.DOTALL)
self.assertRegex(out, regex)
@@ -684,14 +686,14 @@ class PyMemDebugTests(unittest.TestCase):
r"\n"
r"Enable tracemalloc to get the memory block allocation traceback\n"
r"\n"
- r"Fatal Python error: bad ID: Allocated using API 'm', verified using API 'r'\n")
+ r"Fatal Python error: _PyMem_DebugRawFree: bad ID: Allocated using API 'm', verified using API 'r'\n")
regex = regex.format(ptr=self.PTR_REGEX)
self.assertRegex(out, regex)
def check_malloc_without_gil(self, code):
out = self.check(code)
- expected = ('Fatal Python error: Python memory allocator called '
- 'without holding the GIL')
+ expected = ('Fatal Python error: _PyMem_DebugMalloc: '
+ 'Python memory allocator called without holding the GIL')
self.assertIn(expected, out)
def test_pymem_malloc_without_gil(self):