mirror of
https://github.com/python/cpython.git
synced 2024-11-27 11:55:13 +08:00
gh-116012: Preserve GetLastError() across calls to TlsGetValue on Windows (GH-116014)
This commit is contained in:
parent
647053fed1
commit
9578288a3e
@ -0,0 +1 @@
|
||||
Ensure the value of ``GetLastError()`` is preserved across GIL operations.
|
@ -2528,16 +2528,7 @@ PyGILState_Check(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef MS_WINDOWS
|
||||
int err = GetLastError();
|
||||
#endif
|
||||
|
||||
PyThreadState *tcur = gilstate_tss_get(runtime);
|
||||
|
||||
#ifdef MS_WINDOWS
|
||||
SetLastError(err);
|
||||
#endif
|
||||
|
||||
return (tstate == tcur);
|
||||
}
|
||||
|
||||
|
@ -513,5 +513,10 @@ void *
|
||||
PyThread_tss_get(Py_tss_t *key)
|
||||
{
|
||||
assert(key != NULL);
|
||||
return TlsGetValue(key->_key);
|
||||
int err = GetLastError();
|
||||
void *r = TlsGetValue(key->_key);
|
||||
if (r || !GetLastError()) {
|
||||
SetLastError(err);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user