Tim Peters <t...@python.org> added the comment:

Stuff like that happens in any language supporting a tell() function for a file 
opened in text mode on Windows, inherited from the platform C's ftell() 
implementation:

https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/ftell-ftelli64?view=vs-2017

"""
The value returned by ftell and _ftelli64 may not reflect the physical byte 
offset for streams opened in text mode, because text mode causes carriage 
return-linefeed translation.
"""

The _only_ legitimate use for a tell() result from a file opened in text mode 
is to pass it as an argument to fseek() later.

As Zachary said, if you need tell() to return an actual byte offset, you need 
to open the file in binary mode instead.

----------
nosy: +tim.peters
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue36190>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to