summaryrefslogtreecommitdiffstats
path: root/Modules/_io/fileio.c
diff options
context:
space:
mode:
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)",