summaryrefslogtreecommitdiffstats
path: root/Python/thread_nt.h
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@python.org>2024-02-28 13:58:25 (GMT)
committerGitHub <noreply@github.com>2024-02-28 13:58:25 (GMT)
commit9578288a3e5a7f42d1f3bec139c0c85b87775c90 (patch)
tree0fedfac993a7c528c6ed30bf76321e878337344d /Python/thread_nt.h
parent647053fed182066d3b8c934fb0bf52ee48ff3911 (diff)
downloadcpython-9578288a3e5a7f42d1f3bec139c0c85b87775c90.zip
cpython-9578288a3e5a7f42d1f3bec139c0c85b87775c90.tar.gz
cpython-9578288a3e5a7f42d1f3bec139c0c85b87775c90.tar.bz2
gh-116012: Preserve GetLastError() across calls to TlsGetValue on Windows (GH-116014)
Diffstat (limited to 'Python/thread_nt.h')
-rw-r--r--Python/thread_nt.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/Python/thread_nt.h b/Python/thread_nt.h
index 7922b2d..9dca833 100644
--- a/Python/thread_nt.h
+++ b/Python/thread_nt.h
@@ -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;
}