diff Python/ceval.c @ 6365:21b93d98926b legacy-trunk

Change PyEval_SaveThread() and PyEval_RestoreThread() to always do the tstate swapping. Only the acquiring and releasing of the lock is conditional (twice, under ``#ifdef WITH_THREAD'' and inside ``if (interpreter_lock)'').
author Guido van Rossum <guido@python.org>
date Tue, 30 Sep 1997 22:03:16 +0000
parents 4279f4eb210a
children 67a2afcdd21c
line wrap: on
line diff
--- a/Python/ceval.c	Tue Sep 30 22:00:13 1997 +0000
+++ b/Python/ceval.c	Tue Sep 30 22:03:16 1997 +0000
@@ -171,33 +171,30 @@
 PyThreadState *
 PyEval_SaveThread()
 {
+	PyThreadState *tstate = PyThreadState_Swap(NULL);
+	if (tstate == NULL)
+		Py_FatalError("PyEval_SaveThread: NULL tstate");
 #ifdef WITH_THREAD
-	if (interpreter_lock) {
-		PyThreadState *tstate = PyThreadState_Swap(NULL);
-		if (tstate == NULL)
-			Py_FatalError("PyEval_SaveThread: NULL tstate");
+	if (interpreter_lock)
 		release_lock(interpreter_lock);
-		return tstate;
-	}
 #endif
-	return NULL;
+	return tstate;
 }
 
 void
 PyEval_RestoreThread(tstate)
 	PyThreadState *tstate;
 {
+	if (tstate == NULL)
+		Py_FatalError("PyEval_RestoreThread: NULL tstate");
 #ifdef WITH_THREAD
 	if (interpreter_lock) {
-		int err;
-		err = errno;
-		if (tstate == NULL)
-			Py_FatalError("PyEval_RestoreThread: NULL tstate");
+		int err = errno;
 		acquire_lock(interpreter_lock, 1);
-		PyThreadState_Swap(tstate);
 		errno = err;
 	}
 #endif
+	PyThreadState_Swap(tstate);
 }