Wrap thread stuff in WITH_THREAD. Fixes #704641.
diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c
index 3cc6bfa..822a0c3 100644
--- a/Modules/_tkinter.c
+++ b/Modules/_tkinter.c
@@ -329,7 +329,6 @@
 	select(0, (fd_set *)0, (fd_set *)0, (fd_set *)0, &t);
 }
 #endif /* MS_WINDOWS */
-#endif /* WITH_THREAD */
 
 /* Wait up to 1s for the mainloop to come up. */
 
@@ -349,6 +348,7 @@
 	PyErr_SetString(PyExc_RuntimeError, "main thread is not in main loop");
 	return 0;
 }
+#endif /* WITH_THREAD */
 
 
 static char *
@@ -624,11 +624,13 @@
 	    return 0;
 	}
 #endif
+#ifdef WITH_THREAD
 	if (v->threaded && tcl_lock) {
 	    /* If Tcl is threaded, we don't need the lock. */
 	    PyThread_free_lock(tcl_lock);
 	    tcl_lock = NULL;
 	}
+#endif
 
 	v->BooleanType = Tcl_GetObjType("boolean");
 	v->ByteArrayType = Tcl_GetObjType("bytearray");
@@ -1246,6 +1248,7 @@
 	/* Could add TCL_EVAL_GLOBAL if wrapped by GlobalCall... */
 	int flags = TCL_EVAL_DIRECT;
 
+#ifdef WITH_THREAD
 	if (self->threaded && self->thread_id != Tcl_GetCurrentThread()) {
 		/* We cannot call the command directly. Instead, we must
 		   marshal the parameters to the interpreter thread. */
@@ -1272,7 +1275,9 @@
 				PyErr_SetObject(Tkinter_TclError, exc_value);
 		}
 	}
-	else {
+	else 
+#endif
+	{
 
 		objv = Tkapp_CallArgs(args, objStore, &objc);
 		if (!objv)
@@ -1532,6 +1537,7 @@
 	ev->coderesult = coderesult;
 	ev->res = &res;
 	ev->exc = &exc;
+#ifdef WITH_THREAD
 	if (self->threaded && self->thread_id != Tcl_GetCurrentThread()) {
 		/* The current thread is not the interpreter thread.  Marshal
 		   the call to the interpreter thread, then wait for
@@ -1543,7 +1549,9 @@
 		ev->ev.proc = (Tcl_EventProc*)var_proc;
 		Tkapp_ThreadSend(self, (Tcl_Event*)ev, &ev->cond, &var_mutex);
 	}
-	else {
+	else 
+#endif
+	{
 		/* Tcl is not threaded, or this is the interpreter thread.  To
 		   perform the call, we must hold the TCL lock. To receive the
 		   results, we must also hold the Python lock. */
@@ -2049,9 +2057,11 @@
 		return NULL;
 	}
 
+#ifdef WITH_THREAD
 	if (self->threaded && self->thread_id != Tcl_GetCurrentThread() &&
 	    !WaitForMainloop(self))
 		return NULL;
+#endif
 
 	data = PyMem_NEW(PythonCmd_ClientData, 1);
 	if (!data)
@@ -2208,6 +2218,7 @@
 			      &file, &mask, &func))
 		return NULL;
 
+#ifdef WITH_THREAD
 	if (!self && !tcl_lock) {
 		/* We don't have the Tcl lock since Tcl is threaded. */
 		PyErr_SetString(PyExc_RuntimeError,
@@ -2215,6 +2226,7 @@
 				"for threaded Tcl");
 		return NULL;
 	}
+#endif
 
 	if (self) {
 		CHECK_TCL_APPARTMENT;
@@ -2249,6 +2261,7 @@
 	if (!PyArg_ParseTuple(args, "O:deletefilehandler", &file))
 		return NULL;
 
+#ifdef WITH_THREAD
 	if (!self && !tcl_lock) {
 		/* We don't have the Tcl lock since Tcl is threaded. */
 		PyErr_SetString(PyExc_RuntimeError,
@@ -2256,6 +2269,7 @@
 				"for threaded Tcl");
 		return NULL;
 	}
+#endif
 
 	if (self) {
 		CHECK_TCL_APPARTMENT;
@@ -2426,6 +2440,7 @@
 		return NULL;
 	}
 
+#ifdef WITH_THREAD
 	if (!self && !tcl_lock) {
 		/* We don't have the Tcl lock since Tcl is threaded. */
 		PyErr_SetString(PyExc_RuntimeError,
@@ -2433,6 +2448,7 @@
 				"for threaded Tcl");
 		return NULL;
 	}
+#endif
 
 	if (self) {
 		CHECK_TCL_APPARTMENT;
@@ -2460,6 +2476,7 @@
 	if (!PyArg_ParseTuple(args, "|i:mainloop", &threshold))
 		return NULL;
 
+#ifdef WITH_THREAD
 	if (!self && !tcl_lock) {
 		/* We don't have the Tcl lock since Tcl is threaded. */
 		PyErr_SetString(PyExc_RuntimeError,
@@ -2467,6 +2484,7 @@
 				"for threaded Tcl");
 		return NULL;
 	}
+#endif
 
 	if (self) {
 		CHECK_TCL_APPARTMENT;
@@ -2834,7 +2852,9 @@
 }
 #endif
 
+#ifdef WITH_THREAD
 static PyThreadState *event_tstate = NULL;
+#endif
 
 static int
 EventHook(void)