summaryrefslogtreecommitdiffstats
path: root/Modules/_io/fileio.c
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@microsoft.com>2015-03-08 02:14:07 (GMT)
committerSteve Dower <steve.dower@microsoft.com>2015-03-08 02:14:07 (GMT)
commit8acde7dccebd914ec4235f3ed1e9eef53a300978 (patch)
tree3af6da4a9ba7c3da9f4c1e8bb3fbcfc2c4bd08b6 /Modules/_io/fileio.c
parent35a97c0bed8af6cab7ea0fffe374c3369561c444 (diff)
downloadcpython-8acde7dccebd914ec4235f3ed1e9eef53a300978.zip
cpython-8acde7dccebd914ec4235f3ed1e9eef53a300978.tar.gz
cpython-8acde7dccebd914ec4235f3ed1e9eef53a300978.tar.bz2
Issue #23524: Change back to using Windows errors for _Py_fstat instead of the errno shim.
Diffstat (limited to 'Modules/_io/fileio.c')
-rw-r--r--Modules/_io/fileio.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c
index ab9eb8c..0f226ea 100644
--- a/Modules/_io/fileio.c
+++ b/Modules/_io/fileio.c
@@ -182,7 +182,13 @@ check_fd(int fd)
{
#if defined(HAVE_FSTAT) || defined(MS_WINDOWS)
struct _Py_stat_struct buf;
- if (_Py_fstat(fd, &buf) < 0 && errno == EBADF) {
+ if (_Py_fstat(fd, &buf) < 0 &&
+#ifdef MS_WINDOWS
+ GetLastError() == ERROR_INVALID_HANDLE
+#else
+ errno == EBADF
+#endif
+ ) {
PyObject *exc;
char *msg = strerror(EBADF);
exc = PyObject_CallFunction(PyExc_OSError, "(is)",