Sounds like you should just submit a bug report (and a PR with a fix if you
feel up to it). Since a relative seek to position p is typically just
implemented as an absolute seek to position f.tell()+p, this looks like an
odd omission, and I can't remember a reason for it. Looking at the code,
the fix looks pretty easy -- update _io_StringIO_seek_impl() in
Modules/_io/stringio.c.

On Thu, Jan 16, 2020 at 7:19 PM Random832 <random...@fastmail.com> wrote:

> Absolute seeking on a StringIO treats the offset as a character count
> regardless of the contents, so given that there is no "pretend it's UTF-8
> and advance a given number of 'bytes'" machinery anyway, there's no reason
> not to allow seeking relative to the current location or the end of the
> 'file'. The error message is also misleading: "Can't do nonzero
> cur-relative seeks" even when the seek is relative to the end.
> _______________________________________________
> Python-ideas mailing list -- python-ideas@python.org
> To unsubscribe send an email to python-ideas-le...@python.org
> https://mail.python.org/mailman3/lists/python-ideas.python.org/
> Message archived at
> https://mail.python.org/archives/list/python-ideas@python.org/message/SR5XTK7KDIHFT4KCHEV7XFGYFZ335TSQ/
> Code of Conduct: http://python.org/psf/codeofconduct/
>


-- 
--Guido van Rossum (python.org/~guido)
*Pronouns: he/him **(why is my pronoun here?)*
<http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/>
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/FTQ2H57OTQIMSOGC7ZTYXG4XXFEQB32Q/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to