bpo-31719: Fix test_regrtest.test_crashed() on s390x (#3912)
Add a new _testcapi._read_null() function to crash Python in a
reliable way on s390x.
On s390x, ctypes.string_at(0) returns an empty string rather than
crashing.
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
index ef474e0..25df3ed 100644
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -1960,6 +1960,6 @@
Use SuppressCrashReport() to prevent a crash report from popping up.
"""
- import ctypes
+ import _testcapi
with SuppressCrashReport():
- ctypes.string_at(0)
+ _testcapi._read_null()
diff --git a/Lib/test/test_regrtest.py b/Lib/test/test_regrtest.py
index 264c74d..aae2743 100644
--- a/Lib/test/test_regrtest.py
+++ b/Lib/test/test_regrtest.py
@@ -543,6 +543,8 @@
testname)
self.assertEqual(output.splitlines(), all_methods)
+ @unittest.skipIf(sys.platform.startswith('aix'),
+ "support._crash_python() doesn't work on AIX")
def test_crashed(self):
# Any code which causes a crash
code = 'import test.support; test.support._crash_python()'