[issue25849] files, opened in unicode (text): write() returns symbols count, but seek() expect offset in bytes

Марк Коренберг report at bugs.python.org
Sat Dec 12 15:19:49 EST 2015


New submission from Марк Коренберг:

It seems, that we should deprecate .seek() on files, opened in text mode.

Since it is not possible to seek to position between symbols. Yes, it is possible to decode UTF-8 (or other charset) starting from beginning of the file and count symbols, but it is EXTREMELY SLOW, and is not what user expect. If so, seeking from end of file back to begin may be implemented in even more hard and error-prone way.

Moreover, I consider that we should disallow seek in text files except seek() to begin of the file (position 0) or end of file (seek(0, SEEK_END)).

Seel also issue25190 #25190 about something related for that.

----------
components: IO, Library (Lib), Unicode
messages: 256291
nosy: ezio.melotti, haypo, mmarkk
priority: normal
severity: normal
status: open
title: files, opened in unicode (text): write() returns symbols count, but seek() expect offset in bytes
versions: Python 3.3, Python 3.4, Python 3.5, Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25849>
_______________________________________


More information about the Python-bugs-list mailing list