[Python-checkins] cpython (3.5): faulthandler: Test Py_FatalError() with GIL released

victor.stinner python-checkins at python.org
Tue Mar 15 12:26:18 EDT 2016


https://hg.python.org/cpython/rev/c298c6d8b324
changeset: 100546:c298c6d8b324
branch: 3.5
user: Victor Stinner <victor.stinner at gmail.com>
date: Tue Mar 15 17:23:35 2016 +0100
summary:
 faulthandler: Test Py_FatalError() with GIL released
Issue #26558.
files:
 Lib/test/test_faulthandler.py | 8 ++++++++
 Modules/faulthandler.c | 12 ++++++++++--
 2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/Lib/test/test_faulthandler.py b/Lib/test/test_faulthandler.py
--- a/Lib/test/test_faulthandler.py
+++ b/Lib/test/test_faulthandler.py
@@ -185,6 +185,14 @@
 2,
 'xyz')
 
+ def test_fatal_error_without_gil(self):
+ self.check_fatal_error("""
+ import faulthandler
+ faulthandler._fatal_error(b'xyz', True)
+ """,
+ 2,
+ 'xyz')
+
 @unittest.skipIf(sys.platform.startswith('openbsd') and HAVE_THREADS,
 "Issue #12868: sigaltstack() doesn't work on "
 "OpenBSD if Python is compiled with pthread")
diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c
--- a/Modules/faulthandler.c
+++ b/Modules/faulthandler.c
@@ -935,10 +935,18 @@
 faulthandler_fatal_error_py(PyObject *self, PyObject *args)
 {
 char *message;
- if (!PyArg_ParseTuple(args, "y:fatal_error", &message))
+ int release_gil = 0;
+ if (!PyArg_ParseTuple(args, "y|i:fatal_error", &message, &release_gil))
 return NULL;
 faulthandler_suppress_crash_report();
- Py_FatalError(message);
+ if (release_gil) {
+ Py_BEGIN_ALLOW_THREADS
+ Py_FatalError(message);
+ Py_END_ALLOW_THREADS
+ }
+ else {
+ Py_FatalError(message);
+ }
 Py_RETURN_NONE;
 }
 
-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /