[Python-Dev] Bug in _portable_fseek on Windows in 2.7.x
myriachan at gmail.com
Tue Sep 25 15:38:17 EDT 2018
Sorry for mailing about a bug instead of putting in a bug tracker
ticket. The bug tracker's login system just sits there for a minute
then says "an error has occurred".
This line of code is broken in Windows:
_lseeki64 only modifies the kernel's seek position, not the cached
position stored in stdio. This sometimes leads to problems where
fgetpos does not return the correct file pointer.
The solution is to not do that "SIZEOF_FPOS_T >= 8" code at all on
Windows, and just do this instead (or make a new HAVE_FSEEKI64 macro):
return _fseeki64(fp, offset, whence);
3.x is unaffected because it uses the Unix-like FD API in Windows
instead of stdio, in which its usage of _lseeki64 is correct.
More information about the Python-Dev