Thanks to Chris Herborth, the thread primitives now have proper Py*
names in the source code (they already had those for the linker,
through some smart macros; but the source still had the old, un-Py names).
diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c
index 9d68c69..46bf8da 100644
--- a/Modules/_tkinter.c
+++ b/Modules/_tkinter.c
@@ -171,29 +171,29 @@
 
 */
 
-static type_lock tcl_lock = 0;
+static PyThread_type_lock tcl_lock = 0;
 static PyThreadState *tcl_tstate = NULL;
 
 #define ENTER_TCL \
 	{ PyThreadState *tstate = PyThreadState_Get(); Py_BEGIN_ALLOW_THREADS \
-	    acquire_lock(tcl_lock, 1); tcl_tstate = tstate;
+	    PyThread_acquire_lock(tcl_lock, 1); tcl_tstate = tstate;
 
 #define LEAVE_TCL \
-	tcl_tstate = NULL; release_lock(tcl_lock); Py_END_ALLOW_THREADS}
+	tcl_tstate = NULL; PyThread_release_lock(tcl_lock); Py_END_ALLOW_THREADS}
 
 #define ENTER_OVERLAP \
 	Py_END_ALLOW_THREADS
 
 #define LEAVE_OVERLAP_TCL \
-	tcl_tstate = NULL; release_lock(tcl_lock); }
+	tcl_tstate = NULL; PyThread_release_lock(tcl_lock); }
 
 #define ENTER_PYTHON \
 	{ PyThreadState *tstate = tcl_tstate; tcl_tstate = NULL; \
-            release_lock(tcl_lock); PyEval_RestoreThread((tstate)); }
+            PyThread_release_lock(tcl_lock); PyEval_RestoreThread((tstate)); }
 
 #define LEAVE_PYTHON \
 	{ PyThreadState *tstate = PyEval_SaveThread(); \
-            acquire_lock(tcl_lock, 1); tcl_tstate = tstate; }
+            PyThread_acquire_lock(tcl_lock, 1); tcl_tstate = tstate; }
 
 #else
 
@@ -1679,11 +1679,11 @@
 
 #ifdef WITH_THREAD
 		Py_BEGIN_ALLOW_THREADS
-		acquire_lock(tcl_lock, 1);
+		PyThread_acquire_lock(tcl_lock, 1);
 		tcl_tstate = tstate;
 		result = Tcl_DoOneEvent(TCL_DONT_WAIT);
 		tcl_tstate = NULL;
-		release_lock(tcl_lock);
+		PyThread_release_lock(tcl_lock);
 		if (result == 0)
 			Sleep(20);
 		Py_END_ALLOW_THREADS
@@ -1921,13 +1921,13 @@
 #endif
 #if defined(WITH_THREAD) || defined(MS_WINDOWS)
 		Py_BEGIN_ALLOW_THREADS
-		acquire_lock(tcl_lock, 1);
+		PyThread_acquire_lock(tcl_lock, 1);
 		tcl_tstate = event_tstate;
 
 		result = Tcl_DoOneEvent(TCL_DONT_WAIT);
 
 		tcl_tstate = NULL;
-		release_lock(tcl_lock);
+		PyThread_release_lock(tcl_lock);
 		if (result == 0)
 			Sleep(20);
 		Py_END_ALLOW_THREADS
@@ -2014,7 +2014,7 @@
 	Tkapp_Type.ob_type = &PyType_Type;
 
 #ifdef WITH_THREAD
-	tcl_lock = allocate_lock();
+	tcl_lock = PyThread_allocate_lock();
 #endif
 
 	m = Py_InitModule("_tkinter", moduleMethods);
diff --git a/Modules/bsddbmodule.c b/Modules/bsddbmodule.c
index 1bb40e6..ef20624 100644
--- a/Modules/bsddbmodule.c
+++ b/Modules/bsddbmodule.c
@@ -57,7 +57,7 @@
 	DB *di_bsddb;
 	int di_size;	/* -1 means recompute */
 #ifdef WITH_THREAD
-	type_lock di_lock;
+	PyThread_type_lock di_lock;
 #endif
 } bsddbobject;
 
@@ -113,7 +113,7 @@
 
 	dp->di_size = -1;
 #ifdef WITH_THREAD
-	dp->di_lock = allocate_lock();
+	dp->di_lock = PyThread_allocate_lock();
 	if (dp->di_lock == NULL) {
 		PyErr_SetString(BsddbError, "can't allocate lock");
 		Py_DECREF(dp);
@@ -169,7 +169,7 @@
 
 	dp->di_size = -1;
 #ifdef WITH_THREAD
-	dp->di_lock = allocate_lock();
+	dp->di_lock = PyThread_allocate_lock();
 	if (dp->di_lock == NULL) {
 		PyErr_SetString(BsddbError, "can't allocate lock");
 		Py_DECREF(dp);
@@ -225,7 +225,7 @@
 
 	dp->di_size = -1;
 #ifdef WITH_THREAD
-	dp->di_lock = allocate_lock();
+	dp->di_lock = PyThread_allocate_lock();
 	if (dp->di_lock == NULL) {
 		PyErr_SetString(BsddbError, "can't allocate lock");
 		Py_DECREF(dp);
@@ -242,9 +242,9 @@
 {
 #ifdef WITH_THREAD
 	if (dp->di_lock) {
-		acquire_lock(dp->di_lock, 0);
-		release_lock(dp->di_lock);
-		free_lock(dp->di_lock);
+		PyThread_acquire_lock(dp->di_lock, 0);
+		PyThread_release_lock(dp->di_lock);
+		PyThread_free_lock(dp->di_lock);
 		dp->di_lock = NULL;
 	}
 #endif
@@ -262,8 +262,8 @@
 }
 
 #ifdef WITH_THREAD
-#define BSDDB_BGN_SAVE(_dp) Py_BEGIN_ALLOW_THREADS acquire_lock(_dp->di_lock,1);
-#define BSDDB_END_SAVE(_dp) release_lock(_dp->di_lock); Py_END_ALLOW_THREADS
+#define BSDDB_BGN_SAVE(_dp) Py_BEGIN_ALLOW_THREADS PyThread_acquire_lock(_dp->di_lock,1);
+#define BSDDB_END_SAVE(_dp) PyThread_release_lock(_dp->di_lock); Py_END_ALLOW_THREADS
 #else
 #define BSDDB_BGN_SAVE(_dp) Py_BEGIN_ALLOW_THREADS 
 #define BSDDB_END_SAVE(_dp) Py_END_ALLOW_THREADS
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c
index 11b624a..26bb940 100644
--- a/Modules/signalmodule.c
+++ b/Modules/signalmodule.c
@@ -221,7 +221,7 @@
 	if (!PyArg_Parse(args, "(iO)", &sig_num, &obj))
 		return NULL;
 #ifdef WITH_THREAD
-	if (get_thread_ident() != main_thread) {
+	if (PyThread_get_thread_ident() != main_thread) {
 		PyErr_SetString(PyExc_ValueError,
 				"signal only works in main thread");
 		return NULL;
@@ -346,7 +346,7 @@
 	int i;
 
 #ifdef WITH_THREAD
-	main_thread = get_thread_ident();
+	main_thread = PyThread_get_thread_ident();
 	main_pid = getpid();
 #endif
 
@@ -619,7 +619,7 @@
 	if (!is_tripped)
 		return 0;
 #ifdef WITH_THREAD
-	if (get_thread_ident() != main_thread)
+	if (PyThread_get_thread_ident() != main_thread)
 		return 0;
 #endif
 	if (!(f = PyEval_GetFrame()))
@@ -676,7 +676,7 @@
 {
 	if (Handlers[SIGINT].tripped) {
 #ifdef WITH_THREAD
-		if (get_thread_ident() != main_thread)
+		if (PyThread_get_thread_ident() != main_thread)
 			return 0;
 #endif
 		Handlers[SIGINT].tripped = 0;
@@ -689,7 +689,7 @@
 PyOS_AfterFork()
 {
 #ifdef WITH_THREAD
-	main_thread = get_thread_ident();
+	main_thread = PyThread_get_thread_ident();
 	main_pid = getpid();
 #endif
 }
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index 0564e17..ab0014c 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -313,7 +313,7 @@
 /* Lock to allow python interpreter to continue, but only allow one 
    thread to be in gethostbyname */
 #if defined(WITH_THREAD) && !defined(HAVE_GETHOSTBYNAME_R) && !defined(MS_WINDOWS)
-type_lock gethostbyname_lock;
+PyThread_type_lock gethostbyname_lock;
 #endif
 
 
@@ -358,11 +358,11 @@
 	hp = gethostbyname_r(name, &hp_allocated, buf, buf_len, &errnop);
 #else /* not HAVE_GETHOSTBYNAME_R */
 #if defined(WITH_THREAD) && !defined(MS_WINDOWS)
-	acquire_lock(gethostbyname_lock,1);
+	PyThread_acquire_lock(gethostbyname_lock,1);
 #endif
 	hp = gethostbyname(name);
 #if defined(WITH_THREAD) && !defined(MS_WINDOWS)
-	release_lock(gethostbyname_lock);
+	PyThread_release_lock(gethostbyname_lock);
 #endif
 #endif /* HAVE_GETHOSTBYNAME_R */
 	Py_END_ALLOW_THREADS
@@ -1417,11 +1417,11 @@
 	h = gethostbyname_r(name, &hp_allocated, buf, buf_len, &errnop);
 #else /* not HAVE_GETHOSTBYNAME_R */
 #if defined(WITH_THREAD) && !defined(MS_WINDOWS)
-	acquire_lock(gethostbyname_lock,1);
+	PyThread_acquire_lock(gethostbyname_lock,1);
 #endif
 	h = gethostbyname(name);
 #if defined(WITH_THREAD) && !defined(MS_WINDOWS)
-	release_lock(gethostbyname_lock);
+	PyThread_release_lock(gethostbyname_lock);
 #endif
 #endif /* HAVE_GETHOSTBYNAME_R */
 	Py_END_ALLOW_THREADS
@@ -1463,13 +1463,13 @@
 			    &hp_allocated, buf, buf_len, &errnop);
 #else /* not HAVE_GETHOSTBYNAME_R */
 #if defined(WITH_THREAD) && !defined(MS_WINDOWS)
-	acquire_lock(gethostbyname_lock,1);
+	PyThread_acquire_lock(gethostbyname_lock,1);
 #endif
 	h = gethostbyaddr((char *)&addr.sin_addr,
 			  sizeof(addr.sin_addr),
 			  AF_INET);
 #if defined(WITH_THREAD) && !defined(MS_WINDOWS)
-	release_lock(gethostbyname_lock);
+	PyThread_release_lock(gethostbyname_lock);
 #endif
 #endif /* HAVE_GETHOSTBYNAME_R */
 	Py_END_ALLOW_THREADS
@@ -2188,6 +2188,6 @@
 
 	/* Initialize gethostbyname lock */
 #if defined(WITH_THREAD) && !defined(HAVE_GETHOSTBYNAME_R) && !defined(MS_WINDOWS)
-	gethostbyname_lock = allocate_lock();
+	gethostbyname_lock = PyThread_allocate_lock();
 #endif
 }
diff --git a/Modules/stdwinmodule.c b/Modules/stdwinmodule.c
index 8b18f49..ffae730 100644
--- a/Modules/stdwinmodule.c
+++ b/Modules/stdwinmodule.c
@@ -87,11 +87,11 @@
 
 #include "pythread.h"
 
-static type_lock StdwinLock; /* Lock held when interpreter not locked */
+static PyThread_type_lock StdwinLock; /* Lock held when interpreter not locked */
 
-#define BGN_STDWIN Py_BEGIN_ALLOW_THREADS acquire_lock(StdwinLock, 1);
-#define RET_STDWIN release_lock(StdwinLock); Py_BLOCK_THREADS
-#define END_STDWIN release_lock(StdwinLock); Py_END_ALLOW_THREADS
+#define BGN_STDWIN Py_BEGIN_ALLOW_THREADS PyThread_acquire_lock(StdwinLock, 1);
+#define RET_STDWIN PyThread_release_lock(StdwinLock); Py_BLOCK_THREADS
+#define END_STDWIN PyThread_release_lock(StdwinLock); Py_END_ALLOW_THREADS
 
 #else
 
@@ -2659,6 +2659,6 @@
 	    PyDict_SetItemString(d, "error", StdwinError) != 0)
 		return;
 #ifdef WITH_THREAD
-	StdwinLock = allocate_lock();
+	StdwinLock = PyThread_allocate_lock();
 #endif
 }
diff --git a/Modules/threadmodule.c b/Modules/threadmodule.c
index b08ff0b..3d5e4cc 100644
--- a/Modules/threadmodule.c
+++ b/Modules/threadmodule.c
@@ -49,7 +49,7 @@
 
 typedef struct {
 	PyObject_HEAD
-	type_lock lock_lock;
+	PyThread_type_lock lock_lock;
 } lockobject;
 
 staticforward PyTypeObject Locktype;
@@ -61,7 +61,7 @@
 	self = PyObject_NEW(lockobject, &Locktype);
 	if (self == NULL)
 		return NULL;
-	self->lock_lock = allocate_lock();
+	self->lock_lock = PyThread_allocate_lock();
 	if (self->lock_lock == NULL) {
 		PyMem_DEL(self);
 		self = NULL;
@@ -75,15 +75,15 @@
 	lockobject *self;
 {
 	/* Unlock the lock so it's safe to free it */
-	acquire_lock(self->lock_lock, 0);
-	release_lock(self->lock_lock);
+	PyThread_acquire_lock(self->lock_lock, 0);
+	PyThread_release_lock(self->lock_lock);
 	
-	free_lock(self->lock_lock);
+	PyThread_free_lock(self->lock_lock);
 	PyMem_DEL(self);
 }
 
 static PyObject *
-lock_acquire_lock(self, args)
+lock_PyThread_acquire_lock(self, args)
 	lockobject *self;
 	PyObject *args;
 {
@@ -97,7 +97,7 @@
 		i = 1;
 
 	Py_BEGIN_ALLOW_THREADS
-	i = acquire_lock(self->lock_lock, i);
+	i = PyThread_acquire_lock(self->lock_lock, i);
 	Py_END_ALLOW_THREADS
 
 	if (args == NULL) {
@@ -110,7 +110,7 @@
 
 static char acquire_doc[] =
 "acquire([wait]) -> None or Boolean\n\
-(acquire_lock() is an obsolete synonym)\n\
+(PyThread_acquire_lock() is an obsolete synonym)\n\
 \n\
 Lock the lock.  Without argument, this blocks if the lock is already\n\
 locked (even by the same thread), waiting for another thread to release\n\
@@ -120,7 +120,7 @@
 The blocking operation is not interruptible.";
 
 static PyObject *
-lock_release_lock(self, args)
+lock_PyThread_release_lock(self, args)
 	lockobject *self;
 	PyObject *args;
 {
@@ -128,20 +128,20 @@
 		return NULL;
 
 	/* Sanity check: the lock must be locked */
-	if (acquire_lock(self->lock_lock, 0)) {
-		release_lock(self->lock_lock);
+	if (PyThread_acquire_lock(self->lock_lock, 0)) {
+		PyThread_release_lock(self->lock_lock);
 		PyErr_SetString(ThreadError, "release unlocked lock");
 		return NULL;
 	}
 
-	release_lock(self->lock_lock);
+	PyThread_release_lock(self->lock_lock);
 	Py_INCREF(Py_None);
 	return Py_None;
 }
 
 static char release_doc[] =
 "release()\n\
-(release_lock() is an obsolete synonym)\n\
+(PyThread_release_lock() is an obsolete synonym)\n\
 \n\
 Release the lock, allowing another thread that is blocked waiting for\n\
 the lock to acquire the lock.  The lock must be in the locked state,\n\
@@ -155,8 +155,8 @@
 	if (!PyArg_NoArgs(args))
 		return NULL;
 
-	if (acquire_lock(self->lock_lock, 0)) {
-		release_lock(self->lock_lock);
+	if (PyThread_acquire_lock(self->lock_lock, 0)) {
+		PyThread_release_lock(self->lock_lock);
 		return PyInt_FromLong(0L);
 	}
 	return PyInt_FromLong(1L);
@@ -169,10 +169,10 @@
 Return whether the lock is in the locked state.";
 
 static PyMethodDef lock_methods[] = {
-	{"acquire_lock", (PyCFunction)lock_acquire_lock, 0, acquire_doc},
-	{"acquire",      (PyCFunction)lock_acquire_lock, 0, acquire_doc},
-	{"release_lock", (PyCFunction)lock_release_lock, 0, release_doc},
-	{"release",      (PyCFunction)lock_release_lock, 0, release_doc},
+	{"acquire_lock", (PyCFunction)lock_PyThread_acquire_lock, 0, acquire_doc},
+	{"acquire",      (PyCFunction)lock_PyThread_acquire_lock, 0, acquire_doc},
+	{"release_lock", (PyCFunction)lock_PyThread_release_lock, 0, release_doc},
+	{"release",      (PyCFunction)lock_PyThread_release_lock, 0, release_doc},
 	{"locked_lock",  (PyCFunction)lock_locked_lock,  0, locked_doc},
 	{"locked",       (PyCFunction)lock_locked_lock,  0, locked_doc},
 	{NULL,           NULL}		/* sentinel */
@@ -240,18 +240,11 @@
 	PyThreadState_Clear(tstate);
 	PyEval_ReleaseThread(tstate);
 	PyThreadState_Delete(tstate);
-#ifdef __BEOS__
-	/* Dunno if this will cause problems with other ports; the BeOS thread
-	 * support features only 100% renamed functions. [cjh]
-	 */
 	PyThread_exit_thread();
-#else
-	exit_thread();
-#endif
 }
 
 static PyObject *
-thread_start_new_thread(self, fargs)
+thread_PyThread_start_new_thread(self, fargs)
 	PyObject *self; /* Not used */
 	PyObject *fargs;
 {
@@ -286,7 +279,7 @@
 	Py_INCREF(args);
 	Py_XINCREF(keyw);
 	PyEval_InitThreads(); /* Start the interpreter's thread-awareness */
-	if (!start_new_thread(t_bootstrap, (void*) boot)) {
+	if (!PyThread_start_new_thread(t_bootstrap, (void*) boot)) {
 		PyErr_SetString(ThreadError, "can't start new thread\n");
 		Py_DECREF(func);
 		Py_DECREF(args);
@@ -310,7 +303,7 @@
 SystemExit.";
 
 static PyObject *
-thread_exit_thread(self, args)
+thread_PyThread_exit_thread(self, args)
 	PyObject *self; /* Not used */
 	PyObject *args;
 {
@@ -322,27 +315,27 @@
 
 static char exit_doc[] =
 "exit()\n\
-(exit_thread() is an obsolete synonym)\n\
+(PyThread_exit_thread() is an obsolete synonym)\n\
 \n\
 This is synonymous to ``raise SystemExit''.  It will cause the current\n\
 thread to exit silently unless the exception is caught.";
 
 #ifndef NO_EXIT_PROG
 static PyObject *
-thread_exit_prog(self, args)
+thread_PyThread_exit_prog(self, args)
 	PyObject *self; /* Not used */
 	PyObject *args;
 {
 	int sts;
 	if (!PyArg_Parse(args, "i", &sts))
 		return NULL;
-	Py_Exit(sts); /* Calls exit_prog(sts) or _exit_prog(sts) */
+	Py_Exit(sts); /* Calls PyThread_exit_prog(sts) or _PyThread_exit_prog(sts) */
 	for (;;) { } /* Should not be reached */
 }
 #endif
 
 static PyObject *
-thread_allocate_lock(self, args)
+thread_PyThread_allocate_lock(self, args)
 	PyObject *self; /* Not used */
 	PyObject *args;
 {
@@ -365,7 +358,7 @@
 	long ident;
 	if (!PyArg_NoArgs(args))
 		return NULL;
-	ident = get_thread_ident();
+	ident = PyThread_get_thread_ident();
 	if (ident == -1) {
 		PyErr_SetString(ThreadError, "no current thread ident");
 		return NULL;
@@ -385,22 +378,22 @@
 A thread's identity may be reused for another thread after it exits.";
 
 static PyMethodDef thread_methods[] = {
-	{"start_new_thread",	(PyCFunction)thread_start_new_thread, 1,
+	{"start_new_thread",	(PyCFunction)thread_PyThread_start_new_thread, 1,
 				start_new_doc},
-	{"start_new",		(PyCFunction)thread_start_new_thread, 1,
+	{"start_new",		(PyCFunction)thread_PyThread_start_new_thread, 1,
 				start_new_doc},
-	{"allocate_lock",	(PyCFunction)thread_allocate_lock, 0,
+	{"allocate_lock",	(PyCFunction)thread_PyThread_allocate_lock, 0,
 				allocate_doc},
-	{"allocate",		(PyCFunction)thread_allocate_lock, 0,
+	{"allocate",		(PyCFunction)thread_PyThread_allocate_lock, 0,
 				allocate_doc},
-	{"exit_thread",		(PyCFunction)thread_exit_thread, 0,
+	{"exit_thread",		(PyCFunction)thread_PyThread_exit_thread, 0,
 				exit_doc},
-	{"exit",		(PyCFunction)thread_exit_thread, 0,
+	{"exit",		(PyCFunction)thread_PyThread_exit_thread, 0,
 				exit_doc},
 	{"get_ident",		(PyCFunction)thread_get_ident, 0,
 				get_ident_doc},
 #ifndef NO_EXIT_PROG
-	{"exit_prog",		(PyCFunction)thread_exit_prog},
+	{"exit_prog",		(PyCFunction)thread_PyThread_exit_prog},
 #endif
 	{NULL,			NULL}		/* sentinel */
 };
@@ -414,7 +407,7 @@
 
 static char lock_doc[] =
 "A lock object is a synchronization primitive.  To create a lock,\n\
-call the allocate_lock() function.  Methods are:\n\
+call the PyThread_allocate_lock() function.  Methods are:\n\
 \n\
 acquire() -- lock the lock, possibly blocking until it can be obtained\n\
 release() -- unlock of the lock\n\
@@ -441,5 +434,5 @@
 	PyDict_SetItemString(d, "LockType", (PyObject *)&Locktype);
 
 	/* Initialize the C thread library */
-	init_thread();
+	PyThread_init_thread();
 }