[Python-checkins] r68476 - python/trunk/Python/thread_nt.h

kristjan.jonsson python-checkins at python.org
Sat Jan 10 13:14:31 CET 2009


Author: kristjan.jonsson
Date: Sat Jan 10 13:14:31 2009
New Revision: 68476

Log:
Issue 4906:  Preserve windows error state across PyThread_get_key_value

Modified:
   python/trunk/Python/thread_nt.h

Modified: python/trunk/Python/thread_nt.h
==============================================================================
--- python/trunk/Python/thread_nt.h	(original)
+++ python/trunk/Python/thread_nt.h	Sat Jan 10 13:14:31 2009
@@ -315,7 +315,16 @@
 void *
 PyThread_get_key_value(int key)
 {
-	return TlsGetValue(key);
+	/* because TLS is used in the Py_END_ALLOW_THREAD macro,
+	 * it is necessary to preserve the windows error state, because
+	 * it is assumed to be preserved across the call to the macro.
+	 * Ideally, the macro should be fixed, but it is simpler to
+	 * do it here.
+	 */
+	DWORD error = GetLastError();
+	void *result = TlsGetValue(key);
+	SetLastError(error);
+	return result;
 }
 
 void


More information about the Python-checkins mailing list