mirror of
https://github.com/python/cpython.git
synced 2025-07-24 19:54:21 +00:00
gh-116012: Preserve GetLastError() across calls to TlsGetValue on Windows (GH-116014)
This commit is contained in:
parent
647053fed1
commit
9578288a3e
3 changed files with 7 additions and 10 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue