Mercurial > cpython-lru_cache-weakref
diff Python/thread_nt.h @ 50690:5302f806537a legacy-trunk
Issue 4906: Preserve windows error state across PyThread_get_key_value
| author | Kristján Valur Jónsson <kristjan@ccpgames.com> |
|---|---|
| date | Sat, 10 Jan 2009 12:14:31 +0000 |
| parents | fdcca8793eb9 |
| children | 8540268040ff |
line wrap: on
line diff
--- a/Python/thread_nt.h Sat Jan 10 09:18:16 2009 +0000 +++ b/Python/thread_nt.h Sat Jan 10 12:14:31 2009 +0000 @@ -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
