diff -r 4f7c5349e801 Doc/c-api/init.rst --- a/Doc/c-api/init.rst Wed Feb 18 08:05:05 2015 +0200 +++ b/Doc/c-api/init.rst Wed Feb 18 09:25:23 2015 +0200 @@ -817,7 +817,7 @@ been created. the caller should assume no current thread state is available. -.. c:function:: int PyThreadState_SetAsyncExc(long id, PyObject *exc) +.. c:function:: int PyThreadState_SetAsyncExc(unsigned long id, PyObject *exc) Asynchronously raise an exception in a thread. The *id* argument is the thread id of the target thread; *exc* is the exception object to be raised. This diff -r 4f7c5349e801 Include/pystate.h --- a/Include/pystate.h Wed Feb 18 08:05:05 2015 +0200 +++ b/Include/pystate.h Wed Feb 18 09:25:23 2015 +0200 @@ -103,7 +103,7 @@ typedef struct _ts { int gilstate_counter; PyObject *async_exc; /* Asynchronous exception to raise */ - long thread_id; /* Thread id where this tstate was created */ + unsigned long thread_id; /* Thread id where this tstate was created */ int trash_delete_nesting; PyObject *trash_delete_later; @@ -168,7 +168,7 @@ PyAPI_FUNC(void) _PyGILState_Reinit(void PyAPI_FUNC(PyThreadState *) PyThreadState_Get(void); PyAPI_FUNC(PyThreadState *) PyThreadState_Swap(PyThreadState *); PyAPI_FUNC(PyObject *) PyThreadState_GetDict(void); -PyAPI_FUNC(int) PyThreadState_SetAsyncExc(long, PyObject *); +PyAPI_FUNC(int) PyThreadState_SetAsyncExc(unsigned long, PyObject *); /* Variable and macro for in-line access to current thread state */ diff -r 4f7c5349e801 Include/pythread.h --- a/Include/pythread.h Wed Feb 18 08:05:05 2015 +0200 +++ b/Include/pythread.h Wed Feb 18 09:25:23 2015 +0200 @@ -18,9 +18,9 @@ typedef enum PyLockStatus { } PyLockStatus; PyAPI_FUNC(void) PyThread_init_thread(void); -PyAPI_FUNC(long) PyThread_start_new_thread(void (*)(void *), void *); +PyAPI_FUNC(unsigned long) PyThread_start_new_thread(void (*)(void *), void *); PyAPI_FUNC(void) PyThread_exit_thread(void); -PyAPI_FUNC(long) PyThread_get_thread_ident(void); +PyAPI_FUNC(unsigned long) PyThread_get_thread_ident(void); PyAPI_FUNC(PyThread_type_lock) PyThread_allocate_lock(void); PyAPI_FUNC(void) PyThread_free_lock(PyThread_type_lock); diff -r 4f7c5349e801 Lib/_dummy_thread.py --- a/Lib/_dummy_thread.py Wed Feb 18 08:05:05 2015 +0200 +++ b/Lib/_dummy_thread.py Wed Feb 18 09:25:23 2015 +0200 @@ -69,7 +69,7 @@ def get_ident(): available, it is safe to assume that the current process is the only thread. Thus a constant can be safely returned. """ - return -1 + return 1 def allocate_lock(): """Dummy implementation of _thread.allocate_lock().""" diff -r 4f7c5349e801 Lib/test/test_dummy_thread.py --- a/Lib/test/test_dummy_thread.py Wed Feb 18 08:05:05 2015 +0200 +++ b/Lib/test/test_dummy_thread.py Wed Feb 18 09:25:23 2015 +0200 @@ -94,8 +94,7 @@ class MiscTests(unittest.TestCase): #Test sanity of _thread.get_ident() self.assertIsInstance(_thread.get_ident(), int, "_thread.get_ident() returned a non-integer") - self.assertTrue(_thread.get_ident() != 0, - "_thread.get_ident() returned 0") + self.assertGreater(_thread.get_ident(), 0) def test_LockType(self): #Make sure _thread.LockType is the same type as _thread.allocate_locke() diff -r 4f7c5349e801 Lib/test/test_sys.py --- a/Lib/test/test_sys.py Wed Feb 18 08:05:05 2015 +0200 +++ b/Lib/test/test_sys.py Wed Feb 18 09:25:23 2015 +0200 @@ -353,6 +353,9 @@ class SysModuleTest(unittest.TestCase): thread_id = thread_info[0] d = sys._current_frames() + for tid in d: + self.assertIsInstance(tid, int) + self.assertGreaterEqual(tid, 0) main_id = threading.get_ident() self.assertIn(main_id, d) diff -r 4f7c5349e801 Lib/test/test_threading.py --- a/Lib/test/test_threading.py Wed Feb 18 08:05:05 2015 +0200 +++ b/Lib/test/test_threading.py Wed Feb 18 09:25:23 2015 +0200 @@ -186,9 +186,10 @@ class ThreadTests(BaseTestCase): # First check it works when setting the exception from the same thread. tid = threading.get_ident() + self.assertGreaterEqual(tid, 0) try: - result = set_async_exc(ctypes.c_long(tid), exception) + result = set_async_exc(ctypes.c_ulong(tid), exception) # The exception is async, so we might have to keep the VM busy until # it notices. while True: @@ -234,7 +235,7 @@ class ThreadTests(BaseTestCase): # Try a thread id that doesn't make sense. if verbose: print(" trying nonsensical thread id") - result = set_async_exc(ctypes.c_long(-1), exception) + result = set_async_exc(ctypes.c_ulong(-1), exception) self.assertEqual(result, 0) # no thread states modified # Now raise an exception in the worker thread. @@ -247,7 +248,7 @@ class ThreadTests(BaseTestCase): self.assertTrue(not t.finished) if verbose: print(" attempting to raise asynch exception in worker") - result = set_async_exc(ctypes.c_long(t.id), exception) + result = set_async_exc(ctypes.c_ulong(t.id), exception) self.assertEqual(result, 1) # one thread state modified if verbose: print(" waiting for worker to say it caught the exception") diff -r 4f7c5349e801 Modules/_io/bufferedio.c --- a/Modules/_io/bufferedio.c Wed Feb 18 08:05:05 2015 +0200 +++ b/Modules/_io/bufferedio.c Wed Feb 18 09:25:23 2015 +0200 @@ -278,7 +278,7 @@ typedef struct { #ifdef WITH_THREAD PyThread_type_lock lock; - volatile long owner; + volatile unsigned long owner; #endif Py_ssize_t buffer_size; diff -r 4f7c5349e801 Modules/_multiprocessing/semaphore.c --- a/Modules/_multiprocessing/semaphore.c Wed Feb 18 08:05:05 2015 +0200 +++ b/Modules/_multiprocessing/semaphore.c Wed Feb 18 09:25:23 2015 +0200 @@ -14,7 +14,7 @@ enum { RECURSIVE_MUTEX, SEMAPHORE }; typedef struct { PyObject_HEAD SEM_HANDLE handle; - long last_tid; + unsigned long last_tid; int count; int maxvalue; int kind; diff -r 4f7c5349e801 Modules/_sqlite/connection.c --- a/Modules/_sqlite/connection.c Wed Feb 18 08:05:05 2015 +0200 +++ b/Modules/_sqlite/connection.c Wed Feb 18 09:25:23 2015 +0200 @@ -1147,7 +1147,7 @@ int pysqlite_check_thread(pysqlite_Conne if (PyThread_get_thread_ident() != self->thread_ident) { PyErr_Format(pysqlite_ProgrammingError, "SQLite objects created in a thread can only be used in that same thread." - "The object was created in thread id %ld and this is thread id %ld", + "The object was created in thread id %lu and this is thread id %lu", self->thread_ident, PyThread_get_thread_ident()); return 0; } diff -r 4f7c5349e801 Modules/_sqlite/connection.h --- a/Modules/_sqlite/connection.h Wed Feb 18 08:05:05 2015 +0200 +++ b/Modules/_sqlite/connection.h Wed Feb 18 09:25:23 2015 +0200 @@ -66,7 +66,7 @@ typedef struct int initialized; /* thread identification of the thread the connection was created in */ - long thread_ident; + unsigned long thread_ident; pysqlite_Cache* statement_cache; diff -r 4f7c5349e801 Modules/_threadmodule.c --- a/Modules/_threadmodule.c Wed Feb 18 08:05:05 2015 +0200 +++ b/Modules/_threadmodule.c Wed Feb 18 09:25:23 2015 +0200 @@ -256,7 +256,7 @@ static PyTypeObject Locktype = { typedef struct { PyObject_HEAD PyThread_type_lock rlock_lock; - long rlock_owner; + unsigned long rlock_owner; unsigned long rlock_count; PyObject *in_weakreflist; } rlockobject; @@ -285,7 +285,7 @@ rlock_acquire(rlockobject *self, PyObjec int blocking = 1; double timeout = -1; PY_TIMEOUT_T microseconds; - long tid; + unsigned long tid; PyLockStatus r = PY_LOCK_ACQUIRED; if (!PyArg_ParseTupleAndKeywords(args, kwds, "|id:acquire", kwlist, @@ -359,7 +359,7 @@ the lock is taken and its internal count static PyObject * rlock_release(rlockobject *self) { - long tid = PyThread_get_thread_ident(); + unsigned long tid = PyThread_get_thread_ident(); if (self->rlock_count == 0 || self->rlock_owner != tid) { PyErr_SetString(PyExc_RuntimeError, @@ -388,11 +388,11 @@ to be available for other threads."); static PyObject * rlock_acquire_restore(rlockobject *self, PyObject *args) { - long owner; + unsigned long owner; unsigned long count; int r = 1; - if (!PyArg_ParseTuple(args, "(kl):_acquire_restore", &count, &owner)) + if (!PyArg_ParseTuple(args, "(kk):_acquire_restore", &count, &owner)) return NULL; if (!PyThread_acquire_lock(self->rlock_lock, 0)) { @@ -418,7 +418,7 @@ For internal use by `threading.Condition static PyObject * rlock_release_save(rlockobject *self) { - long owner; + unsigned long owner; unsigned long count; if (self->rlock_count == 0) { @@ -432,7 +432,7 @@ rlock_release_save(rlockobject *self) self->rlock_count = 0; self->rlock_owner = 0; PyThread_release_lock(self->rlock_lock); - return Py_BuildValue("kl", count, owner); + return Py_BuildValue("kk", count, owner); } PyDoc_STRVAR(rlock_release_save_doc, @@ -444,7 +444,7 @@ For internal use by `threading.Condition static PyObject * rlock_is_owned(rlockobject *self) { - long tid = PyThread_get_thread_ident(); + unsigned long tid = PyThread_get_thread_ident(); if (self->rlock_count > 0 && self->rlock_owner == tid) { Py_RETURN_TRUE; @@ -1043,7 +1043,7 @@ thread_PyThread_start_new_thread(PyObjec { PyObject *func, *args, *keyw = NULL; struct bootstate *boot; - long ident; + unsigned long ident; if (!PyArg_UnpackTuple(fargs, "start_new_thread", 2, 3, &func, &args, &keyw)) @@ -1080,7 +1080,7 @@ thread_PyThread_start_new_thread(PyObjec Py_XINCREF(keyw); PyEval_InitThreads(); /* Start the interpreter's thread-awareness */ ident = PyThread_start_new_thread(t_bootstrap, (void*) boot); - if (ident == -1) { + if (ident == (unsigned long)-1) { PyErr_SetString(ThreadError, "can't start new thread"); Py_DECREF(func); Py_DECREF(args); @@ -1089,7 +1089,7 @@ thread_PyThread_start_new_thread(PyObjec PyMem_DEL(boot); return NULL; } - return PyLong_FromLong(ident); + return PyLong_FromUnsignedLong(ident); } PyDoc_STRVAR(start_new_doc, @@ -1149,13 +1149,13 @@ Create a new lock object. See help(Lock static PyObject * thread_get_ident(PyObject *self) { - long ident; + unsigned long ident; ident = PyThread_get_thread_ident(); - if (ident == -1) { + if (ident == (unsigned long)-1) { PyErr_SetString(ThreadError, "no current thread ident"); return NULL; } - return PyLong_FromLong(ident); + return PyLong_FromUnsignedLong(ident); } PyDoc_STRVAR(get_ident_doc, diff -r 4f7c5349e801 Modules/faulthandler.c --- a/Modules/faulthandler.c Wed Feb 18 08:05:05 2015 +0200 +++ b/Modules/faulthandler.c Wed Feb 18 09:25:23 2015 +0200 @@ -580,7 +580,7 @@ faulthandler_dump_traceback_later(PyObje /* Arm these locks to serve as events when released */ PyThread_acquire_lock(thread.running, 1); - if (PyThread_start_new_thread(faulthandler_thread, NULL) == -1) { + if (PyThread_start_new_thread(faulthandler_thread, NULL) == (unsigned long)-1) { PyThread_release_lock(thread.running); Py_CLEAR(thread.file); PyMem_Free(header); diff -r 4f7c5349e801 Modules/signalmodule.c --- a/Modules/signalmodule.c Wed Feb 18 08:05:05 2015 +0200 +++ b/Modules/signalmodule.c Wed Feb 18 09:25:23 2015 +0200 @@ -81,7 +81,7 @@ #ifdef WITH_THREAD #include /* For pid_t */ #include "pythread.h" -static long main_thread; +static unsigned long main_thread; static pid_t main_pid; #endif @@ -1014,11 +1014,11 @@ nanoseconds)."); static PyObject * signal_pthread_kill(PyObject *self, PyObject *args) { - long tid; + unsigned long tid; int signum; int err; - if (!PyArg_ParseTuple(args, "li:pthread_kill", &tid, &signum)) + if (!PyArg_ParseTuple(args, "ki:pthread_kill", &tid, &signum)) return NULL; err = pthread_kill((pthread_t)tid, signum); diff -r 4f7c5349e801 Python/ceval.c --- a/Python/ceval.c Wed Feb 18 08:05:05 2015 +0200 +++ b/Python/ceval.c Wed Feb 18 09:25:23 2015 +0200 @@ -283,7 +283,7 @@ PyEval_GetCallStats(PyObject *self) #include "pythread.h" static PyThread_type_lock pending_lock = 0; /* for pending calls */ -static long main_thread = 0; +static unsigned long main_thread = 0; /* This single variable consolidates all requests to break out of the fast path in the eval loop. */ static _Py_atomic_int eval_breaker = {0}; diff -r 4f7c5349e801 Python/import.c --- a/Python/import.c Wed Feb 18 08:05:05 2015 +0200 +++ b/Python/import.c Wed Feb 18 09:25:23 2015 +0200 @@ -156,14 +156,14 @@ void #include "pythread.h" static PyThread_type_lock import_lock = 0; -static long import_lock_thread = -1; +static unsigned long import_lock_thread = (unsigned long)-1; static int import_lock_level = 0; void _PyImport_AcquireLock(void) { - long me = PyThread_get_thread_ident(); - if (me == -1) + unsigned long me = PyThread_get_thread_ident(); + if (me == (unsigned long)-1) return; /* Too bad */ if (import_lock == NULL) { import_lock = PyThread_allocate_lock(); @@ -174,7 +174,8 @@ void import_lock_level++; return; } - if (import_lock_thread != -1 || !PyThread_acquire_lock(import_lock, 0)) + if (import_lock_thread != (unsigned long)-1 || + !PyThread_acquire_lock(import_lock, 0)) { PyThreadState *tstate = PyEval_SaveThread(); PyThread_acquire_lock(import_lock, 1); @@ -188,15 +189,15 @@ void int _PyImport_ReleaseLock(void) { - long me = PyThread_get_thread_ident(); - if (me == -1 || import_lock == NULL) + unsigned long me = PyThread_get_thread_ident(); + if (me == (unsigned long)-1 || import_lock == NULL) return 0; /* Too bad */ if (import_lock_thread != me) return -1; import_lock_level--; assert(import_lock_level >= 0); if (import_lock_level == 0) { - import_lock_thread = -1; + import_lock_thread = (unsigned long)-1; PyThread_release_lock(import_lock); } return 1; @@ -214,7 +215,7 @@ void import_lock = PyThread_allocate_lock(); if (import_lock_level > 1) { /* Forked as a side effect of import */ - long me = PyThread_get_thread_ident(); + unsigned long me = PyThread_get_thread_ident(); /* The following could fail if the lock is already held, but forking as a side-effect of an import is a) rare, b) nuts, and c) difficult to do thanks to the lock only being held when doing individual module @@ -223,7 +224,7 @@ void import_lock_thread = me; import_lock_level--; } else { - import_lock_thread = -1; + import_lock_thread = (unsigned long)-1; import_lock_level = 0; } } @@ -243,7 +244,7 @@ static PyObject * /*[clinic end generated code: output=d7a8cc3a5169081a input=9b088f9b217d9bdf]*/ { #ifdef WITH_THREAD - return PyBool_FromLong(import_lock_thread != -1); + return PyBool_FromLong(import_lock_thread != (unsigned long)-1); #else return PyBool_FromLong(0); #endif diff -r 4f7c5349e801 Python/pystate.c --- a/Python/pystate.c Wed Feb 18 08:05:05 2015 +0200 +++ b/Python/pystate.c Wed Feb 18 09:25:23 2015 +0200 @@ -539,7 +539,7 @@ PyThreadState_GetDict(void) existing async exception. This raises no exceptions. */ int -PyThreadState_SetAsyncExc(long id, PyObject *exc) { +PyThreadState_SetAsyncExc(unsigned long id, PyObject *exc) { PyThreadState *tstate = PyThreadState_GET(); PyInterpreterState *interp = tstate->interp; PyThreadState *p; @@ -628,7 +628,7 @@ PyObject * struct _frame *frame = t->frame; if (frame == NULL) continue; - id = PyLong_FromLong(t->thread_id); + id = PyLong_FromUnsignedLong(t->thread_id); if (id == NULL) goto Fail; stat = PyDict_SetItem(result, id, (PyObject *)frame); diff -r 4f7c5349e801 Python/thread.c --- a/Python/thread.c Wed Feb 18 08:05:05 2015 +0200 +++ b/Python/thread.c Wed Feb 18 09:25:23 2015 +0200 @@ -172,7 +172,7 @@ struct key { struct key *next; /* The thread id, according to PyThread_get_thread_ident(). */ - long id; + unsigned long id; /* The key and its associated value. */ int key; @@ -208,7 +208,7 @@ static struct key * find_key(int set_value, int key, void *value) { struct key *p, *prev_p; - long id = PyThread_get_thread_ident(); + unsigned long id = PyThread_get_thread_ident(); if (!keymutex) return NULL; @@ -312,7 +312,7 @@ PyThread_get_key_value(int key) void PyThread_delete_key_value(int key) { - long id = PyThread_get_thread_ident(); + unsigned long id = PyThread_get_thread_ident(); struct key *p, **q; PyThread_acquire_lock(keymutex, 1); @@ -338,7 +338,7 @@ PyThread_delete_key_value(int key) void PyThread_ReInitTLS(void) { - long id = PyThread_get_thread_ident(); + unsigned long id = PyThread_get_thread_ident(); struct key *p, **q; if (!keymutex) diff -r 4f7c5349e801 Python/thread_foobar.h --- a/Python/thread_foobar.h Wed Feb 18 08:05:05 2015 +0200 +++ b/Python/thread_foobar.h Wed Feb 18 09:25:23 2015 +0200 @@ -9,7 +9,7 @@ PyThread__init_thread(void) /* * Thread support. */ -long +unsigned long PyThread_start_new_thread(void (*func)(void *), void *arg) { int success = 0; /* init not needed when SOLARIS_THREADS and */ @@ -18,10 +18,10 @@ PyThread_start_new_thread(void (*func)(v dprintf(("PyThread_start_new_thread called\n")); if (!initialized) PyThread_init_thread(); - return success < 0 ? -1 : 0; + return success < 0 ? (unsigned long)-1 : 0; } -long +unsigned long PyThread_get_thread_ident(void) { if (!initialized) diff -r 4f7c5349e801 Python/thread_nt.h --- a/Python/thread_nt.h Wed Feb 18 08:05:05 2015 +0200 +++ b/Python/thread_nt.h Wed Feb 18 09:25:23 2015 +0200 @@ -140,7 +140,7 @@ LeaveNonRecursiveMutex(PNRMUTEX mutex) } #endif /* _PY_USE_CV_LOCKS */ -long PyThread_get_thread_ident(void); +unsigned long PyThread_get_thread_ident(void); /* * Initialization of the C package, should not be needed. @@ -176,21 +176,21 @@ bootstrap(void *call) return 0; } -long +unsigned long PyThread_start_new_thread(void (*func)(void *), void *arg) { HANDLE hThread; unsigned threadID; callobj *obj; - dprintf(("%ld: PyThread_start_new_thread called\n", + dprintf(("%lu: PyThread_start_new_thread called\n", PyThread_get_thread_ident())); if (!initialized) PyThread_init_thread(); obj = (callobj*)HeapAlloc(GetProcessHeap(), 0, sizeof(*obj)); if (!obj) - return -1; + return (unsigned long)-1; obj->func = func; obj->arg = arg; #if defined(MS_WINCE) @@ -209,32 +209,32 @@ PyThread_start_new_thread(void (*func)(v /* Save error in variable, to prevent PyThread_get_thread_ident from clobbering it. */ unsigned e = GetLastError(); - dprintf(("%ld: PyThread_start_new_thread failed, win32 error code %u\n", + dprintf(("%lu: PyThread_start_new_thread failed, win32 error code %u\n", PyThread_get_thread_ident(), e)); #else /* I've seen errno == EAGAIN here, which means "there are * too many threads". */ int e = errno; - dprintf(("%ld: PyThread_start_new_thread failed, errno %d\n", + dprintf(("%lu: PyThread_start_new_thread failed, errno %d\n", PyThread_get_thread_ident(), e)); #endif threadID = (unsigned)-1; HeapFree(GetProcessHeap(), 0, obj); } else { - dprintf(("%ld: PyThread_start_new_thread succeeded: %p\n", + dprintf(("%lu: PyThread_start_new_thread succeeded: %p\n", PyThread_get_thread_ident(), (void*)hThread)); CloseHandle(hThread); } - return (long) threadID; + return threadID; } /* * Return the thread Id instead of an handle. The Id is said to uniquely identify the * thread in the system */ -long +unsigned long PyThread_get_thread_ident(void) { if (!initialized) @@ -246,7 +246,7 @@ PyThread_get_thread_ident(void) void PyThread_exit_thread(void) { - dprintf(("%ld: PyThread_exit_thread called\n", PyThread_get_thread_ident())); + dprintf(("%lu: PyThread_exit_thread called\n", PyThread_get_thread_ident())); if (!initialized) exit(0); #if defined(MS_WINCE) @@ -272,7 +272,7 @@ PyThread_allocate_lock(void) aLock = AllocNonRecursiveMutex() ; - dprintf(("%ld: PyThread_allocate_lock() -> %p\n", PyThread_get_thread_ident(), aLock)); + dprintf(("%lu: PyThread_allocate_lock() -> %p\n", PyThread_get_thread_ident(), aLock)); return (PyThread_type_lock) aLock; } @@ -280,7 +280,7 @@ PyThread_allocate_lock(void) void PyThread_free_lock(PyThread_type_lock aLock) { - dprintf(("%ld: PyThread_free_lock(%p) called\n", PyThread_get_thread_ident(),aLock)); + dprintf(("%lu: PyThread_free_lock(%p) called\n", PyThread_get_thread_ident(),aLock)); FreeNonRecursiveMutex(aLock) ; } @@ -311,7 +311,7 @@ PyThread_acquire_lock_timed(PyThread_typ else milliseconds = INFINITE; - dprintf(("%ld: PyThread_acquire_lock_timed(%p, %lld) called\n", + dprintf(("%lu: PyThread_acquire_lock_timed(%p, %lld) called\n", PyThread_get_thread_ident(), aLock, microseconds)); if (aLock && EnterNonRecursiveMutex((PNRMUTEX)aLock, @@ -322,7 +322,7 @@ PyThread_acquire_lock_timed(PyThread_typ success = PY_LOCK_FAILURE; } - dprintf(("%ld: PyThread_acquire_lock(%p, %lld) -> %d\n", + dprintf(("%lu: PyThread_acquire_lock(%p, %lld) -> %d\n", PyThread_get_thread_ident(), aLock, microseconds, success)); return success; @@ -336,10 +336,10 @@ PyThread_acquire_lock(PyThread_type_lock void PyThread_release_lock(PyThread_type_lock aLock) { - dprintf(("%ld: PyThread_release_lock(%p) called\n", PyThread_get_thread_ident(),aLock)); + dprintf(("%lu: PyThread_release_lock(%p) called\n", PyThread_get_thread_ident(),aLock)); if (!(aLock && LeaveNonRecursiveMutex((PNRMUTEX) aLock))) - dprintf(("%ld: Could not PyThread_release_lock(%p) error: %ld\n", PyThread_get_thread_ident(), aLock, GetLastError())); + dprintf(("%lu: Could not PyThread_release_lock(%p) error: %ld\n", PyThread_get_thread_ident(), aLock, GetLastError())); } /* minimum/maximum thread stack sizes supported */ diff -r 4f7c5349e801 Python/thread_pthread.h --- a/Python/thread_pthread.h Wed Feb 18 08:05:05 2015 +0200 +++ b/Python/thread_pthread.h Wed Feb 18 09:25:23 2015 +0200 @@ -182,7 +182,7 @@ PyThread__init_thread(void) */ -long +unsigned long PyThread_start_new_thread(void (*func)(void *), void *arg) { pthread_t th; @@ -200,7 +200,7 @@ PyThread_start_new_thread(void (*func)(v #if defined(THREAD_STACK_SIZE) || defined(PTHREAD_SYSTEM_SCHED_SUPPORTED) if (pthread_attr_init(&attrs) != 0) - return -1; + return (unsigned long)-1; #endif #if defined(THREAD_STACK_SIZE) tss = (_pythread_stacksize != 0) ? _pythread_stacksize @@ -208,7 +208,7 @@ PyThread_start_new_thread(void (*func)(v if (tss != 0) { if (pthread_attr_setstacksize(&attrs, tss) != 0) { pthread_attr_destroy(&attrs); - return -1; + return (unsigned long)-1; } } #endif @@ -230,31 +230,31 @@ PyThread_start_new_thread(void (*func)(v pthread_attr_destroy(&attrs); #endif if (status != 0) - return -1; + return (unsigned long)-1; pthread_detach(th); #if SIZEOF_PTHREAD_T <= SIZEOF_LONG - return (long) th; + return (unsigned long) th; #else - return (long) *(long *) &th; + return (unsigned long) *(unsigned long *) &th; #endif } /* XXX This implementation is considered (to quote Tim Peters) "inherently hosed" because: - It does not guarantee the promise that a non-zero integer is returned. - - The cast to long is inherently unsafe. + - The cast to unsigned long is inherently unsafe. - It is not clear that the 'volatile' (for AIX?) are any longer necessary. */ -long +unsigned long PyThread_get_thread_ident(void) { volatile pthread_t threadid; if (!initialized) PyThread_init_thread(); threadid = pthread_self(); - return (long) threadid; + return (unsigned long) threadid; } void