summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorKristján Valur Jónsson <kristjan@ccpgames.com>2009-01-10 12:14:31 (GMT)
committerKristján Valur Jónsson <kristjan@ccpgames.com>2009-01-10 12:14:31 (GMT)
commitabb70e9c9f79dd26e71368f9aab77ad72d0706bc (patch)
tree4c89fcb237cef4f8a182da788bb467bfbac9f5f8 /Python
parentdbf558888e49fefcff912ac2729c7b1ab2cb6ae7 (diff)
downloadcpython-abb70e9c9f79dd26e71368f9aab77ad72d0706bc.zip
cpython-abb70e9c9f79dd26e71368f9aab77ad72d0706bc.tar.gz
cpython-abb70e9c9f79dd26e71368f9aab77ad72d0706bc.tar.bz2
Issue 4906: Preserve windows error state across PyThread_get_key_value
Diffstat (limited to 'Python')
-rw-r--r--Python/thread_nt.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/Python/thread_nt.h b/Python/thread_nt.h
index 5ec15f6..e0457a2 100644
--- a/Python/thread_nt.h
+++ b/Python/thread_nt.h
@@ -315,7 +315,16 @@ PyThread_set_key_value(int key, void *value)
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