Repository navigation
gh-159677: fix FileIO.seekable incorrectly returning false - #159678
KowalskiThomas wants to merge 3 commits into
Conversation
|
Seems like the Docs check has flaked :| |
| Py_END_ALLOW_THREADS | ||
|
|
||
| if (self->seekable < 0) { | ||
| if (self->seekable < 0 && (res >= 0 || errno == ESPIPE || posobj == NULL)) { |
There was a problem hiding this comment.
Not sure across the set of OS + kernel + version which Python runs on this is correct... Can work on evaluating that thoroughly but my leaning would be just making it so specific returns we know about that indicate "bad argument" pass through.
For instance EBADF should probably still mark seekable as False / I could see code relying on that. Something like: EINVAL, ENXIO, EOVERFLOW for Linux; EBADF and EINVAL for OpenBSD.
There was a problem hiding this comment.
The idea here was that only in the following cases we're 100% sure we know for sure what seekable should be:
res >= 0i.e. it succeedederrno == ESPIPEi.e. Illegal seekposobj == NULLi.e.offset == 0in which case a failure would indicate a seek forSEEK_CUR/SEEK_ENDfailed (so the problem is the file itself) => it's OK to cache the result of seeking directly
If we don't set the cache, "someone else" hopefully will later, but at least we're sure we never store a false value here.
Does that sound reasonable?
Fixes gh-159677.