summaryrefslogtreecommitdiffstats
path: root/Modules/faulthandler.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-04-07 09:50:25 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-04-07 09:50:25 (GMT)
commitff4cd88266b37d266ca607073d9a1122110ef701 (patch)
tree935d6f368bd5b94a3cb3cdd537391950aff58602 /Modules/faulthandler.c
parent44e31baf958b31c3eb0b79b4e5c7176b4c6d11a7 (diff)
downloadcpython-ff4cd88266b37d266ca607073d9a1122110ef701.zip
cpython-ff4cd88266b37d266ca607073d9a1122110ef701.tar.gz
cpython-ff4cd88266b37d266ca607073d9a1122110ef701.tar.bz2
faulthandler: fix compilating without threads
Diffstat (limited to 'Modules/faulthandler.c')
-rw-r--r--Modules/faulthandler.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c
index cfbfda6..76cadf3 100644
--- a/Modules/faulthandler.c
+++ b/Modules/faulthandler.c
@@ -250,6 +250,7 @@ faulthandler_fatal_error(int signum)
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 @@ faulthandler_fatal_error(int signum)
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 @@ faulthandler_user(int signum)
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);