mirror of
https://github.com/python/cpython.git
synced 2025-07-28 21:55:21 +00:00
Issue 4906: Preserve windows error state across PyThread_get_key_value
This commit is contained in:
parent
dbf558888e
commit
abb70e9c9f
1 changed files with 10 additions and 1 deletions
|
@ -315,7 +315,16 @@ PyThread_set_key_value(int key, void *value)
|
||||||
void *
|
void *
|
||||||
PyThread_get_key_value(int key)
|
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
|
void
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue