diff options
author | Steve Dower <steve.dower@microsoft.com> | 2015-03-07 18:14:07 -0800 |
---|---|---|
committer | Steve Dower <steve.dower@microsoft.com> | 2015-03-07 18:14:07 -0800 |
commit | 2d72ea4b9806468c66ac0562db71d5b4faeaea58 (patch) | |
tree | 4f4773b8294f95aba3de173552abf03a9adc1370 /Python/fileutils.c | |
parent | ea83cf646de5c274ca6528be1a78e886192e0780 (diff) | |
download | cpython-2d72ea4b9806468c66ac0562db71d5b4faeaea58.tar.gz |
Issue #23524: Change back to using Windows errors for _Py_fstat instead of the errno shim.
Diffstat (limited to 'Python/fileutils.c')
-rw-r--r-- | Python/fileutils.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Python/fileutils.c b/Python/fileutils.c index c0dbc86a93..6502823535 100644 --- a/Python/fileutils.c +++ b/Python/fileutils.c @@ -637,10 +637,14 @@ _Py_fstat(int fd, struct _Py_stat_struct *result) else h = (HANDLE)_get_osfhandle(fd); + /* Protocol violation: we explicitly clear errno, instead of + setting it to a POSIX error. Callers should use GetLastError. */ errno = 0; if (h == INVALID_HANDLE_VALUE) { - errno = EBADF; + /* This is really a C library error (invalid file handle). + We set the Win32 error to the closes one matching. */ + SetLastError(ERROR_INVALID_HANDLE); return -1; } memset(result, 0, sizeof(*result)); @@ -649,7 +653,6 @@ _Py_fstat(int fd, struct _Py_stat_struct *result) if (type == FILE_TYPE_UNKNOWN) { DWORD error = GetLastError(); if (error != 0) { - errno = EINVAL; return -1; } /* else: valid but unknown file */ @@ -664,7 +667,6 @@ _Py_fstat(int fd, struct _Py_stat_struct *result) } if (!GetFileInformationByHandle(h, &info)) { - errno = EINVAL; return -1; } |