Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ensure the value of ``GetLastError()`` is preserved across GIL operations.
9 changes: 0 additions & 9 deletions Python/pystate.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
7 changes: 6 additions & 1 deletion Python/thread_nt.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}