Skip to content

Commit 9a0d10f

Browse files
committed
Check error
1 parent 7fe3490 commit 9a0d10f

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

Modules/posixmodule.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@
219219
# if defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM)
220220
# define HAVE_SYMLINK
221221
# endif /* MS_WINDOWS_DESKTOP | MS_WINDOWS_SYSTEM */
222+
extern int winerror_to_errno(int);
222223
#endif
223224

224225

@@ -11438,6 +11439,7 @@ os_lseek_impl(PyObject *module, int fd, Py_off_t position, int how)
1143811439
if (result >= 0) {
1143911440
if (GetFileType(h) != FILE_TYPE_DISK) {
1144011441
// Only file is seekable
11442+
errno = ESPIPE;
1144111443
result = -1;
1144211444
}
1144311445
}
@@ -11455,8 +11457,14 @@ os_lseek_impl(PyObject *module, int fd, Py_off_t position, int how)
1145511457
#endif
1145611458
_Py_END_SUPPRESS_IPH
1145711459
Py_END_ALLOW_THREADS
11458-
if (result < 0)
11460+
if (result < 0) {
11461+
#ifdef MS_WINDOWS
11462+
if (errno == 0) {
11463+
errno = winerror_to_errno(GetLastError());
11464+
}
11465+
#endif
1145911466
posix_error();
11467+
}
1146011468

1146111469
return result;
1146211470
}

0 commit comments

Comments
 (0)