[Python-checkins] cpython: faulthandler: fix compilating without threads
victor.stinner
python-checkins at python.org
Thu Apr 7 11:51:32 CEST 2011
http://hg.python.org/cpython/rev/6adbf5f3dafb
changeset: 69184:6adbf5f3dafb
user: Victor Stinner <victor.stinner at haypocalc.com>
date: Thu Apr 07 11:50:25 2011 +0200
summary:
faulthandler: fix compilating without threads
files:
Lib/test/test_faulthandler.py | 7 +++++++
Modules/faulthandler.c | 8 ++++++++
2 files changed, 15 insertions(+), 0 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
@@ -8,6 +8,12 @@
import tempfile
import unittest
+try:
+ import threading
+ HAVE_THREADS = True
+except ImportError:
+ HAVE_THREADS = False
+
TIMEOUT = 0.5
try:
@@ -279,6 +285,7 @@
with temporary_filename() as filename:
self.check_dump_traceback(filename)
+ @unittest.skipIf(not HAVE_THREADS, 'need threads')
def check_dump_traceback_threads(self, filename):
"""
Call explicitly dump_traceback(all_threads=True) and check the output.
diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c
--- a/Modules/faulthandler.c
+++ b/Modules/faulthandler.c
@@ -250,6 +250,7 @@
PUTS(fd, handler->name);
PUTS(fd, "\n\n");
+#ifdef WITH_THREAD
/* SIGSEGV, SIGFPE, SIGABRT, SIGBUS and SIGILL are synchronous signals and
so are delivered to the thread that caused the fault. Get the Python
thread state of the current thread.
@@ -259,6 +260,9 @@
used. Read the thread local storage (TLS) instead: call
PyGILState_GetThisThreadState(). */
tstate = PyGILState_GetThisThreadState();
+#else
+ tstate = PyThreadState_Get();
+#endif
if (tstate == NULL)
return;
@@ -540,10 +544,14 @@
if (!user->enabled)
return;
+#ifdef WITH_THREAD
/* PyThreadState_Get() doesn't give the state of the current thread if
the thread doesn't hold the GIL. Read the thread local storage (TLS)
instead: call PyGILState_GetThisThreadState(). */
tstate = PyGILState_GetThisThreadState();
+#else
+ tstate = PyThreadState_Get();
+#endif
if (user->all_threads)
_Py_DumpTracebackThreads(user->fd, user->interp, tstate);
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list