-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
gh-86768: check if fd is seekable in os.lseek on Windows #133137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
43956d8
b1a5cbb
7fe3490
9a0d10f
2a8efe2
2f851cf
6aad19e
a89aba6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -219,6 +219,7 @@ | |
# if defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) | ||
# define HAVE_SYMLINK | ||
# endif /* MS_WINDOWS_DESKTOP | MS_WINDOWS_SYSTEM */ | ||
extern int winerror_to_errno(int); | ||
#endif | ||
|
||
|
||
|
@@ -11438,6 +11439,7 @@ os_lseek_impl(PyObject *module, int fd, Py_off_t position, int how) | |
if (result >= 0) { | ||
if (GetFileType(h) != FILE_TYPE_DISK) { | ||
// Only file is seekable | ||
errno = ESPIPE; | ||
result = -1; | ||
} | ||
} | ||
|
@@ -11455,8 +11457,14 @@ os_lseek_impl(PyObject *module, int fd, Py_off_t position, int how) | |
#endif | ||
_Py_END_SUPPRESS_IPH | ||
Py_END_ALLOW_THREADS | ||
if (result < 0) | ||
if (result < 0) { | ||
#ifdef MS_WINDOWS | ||
if (errno == 0) { | ||
errno = winerror_to_errno(GetLastError()); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
#endif | ||
posix_error(); | ||
} | ||
|
||
return result; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No longer used.