Skip to content

Commit 2f851cf

Browse files
committed
Simplify the implmentation
1 parent 2a8efe2 commit 2f851cf

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

Modules/posixmodule.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11407,7 +11407,7 @@ static Py_off_t
1140711407
os_lseek_impl(PyObject *module, int fd, Py_off_t position, int how)
1140811408
/*[clinic end generated code: output=971e1efb6b30bd2f input=f096e754c5367504]*/
1140911409
{
11410-
Py_off_t result = 0;
11410+
Py_off_t result = -1;
1141111411

1141211412
#ifdef SEEK_SET
1141311413
/* Turn 0, 1, 2 into SEEK_{SET,CUR,END} */
@@ -11422,19 +11422,14 @@ os_lseek_impl(PyObject *module, int fd, Py_off_t position, int how)
1142211422
_Py_BEGIN_SUPPRESS_IPH
1142311423
#ifdef MS_WINDOWS
1142411424
HANDLE h = (HANDLE)_get_osfhandle(fd);
11425-
if (h == INVALID_HANDLE_VALUE) {
11426-
result = -1;
11427-
}
11428-
if (result >= 0) {
11429-
if (GetFileType(h) != FILE_TYPE_DISK) {
11425+
if (h != INVALID_HANDLE_VALUE) {
11426+
if (GetFileType(h) == FILE_TYPE_DISK) {
11427+
result = _lseeki64(fd, position, how);
11428+
} else {
1143011429
// Only file is seekable
1143111430
errno = ESPIPE;
11432-
result = -1;
1143311431
}
1143411432
}
11435-
if (result >= 0) {
11436-
result = _lseeki64(fd, position, how);
11437-
}
1143811433
#else
1143911434
result = lseek(fd, position, how);
1144011435
#endif

0 commit comments

Comments
 (0)