Message360284
That documentation isn't specific to StringIO, and in any case, the limitation in question isn't documented. The actual implementation is at https://github.com/python/cpython/blob/HEAD/Modules/_io/stringio.c#L484
But if examples would help, they're simple to come up with:
>>> f = io.StringIO('t\xe9st')
>>> f.seek(-1, io.SEEK_END)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: Can't do nonzero cur-relative seeks
>>> f.seek(2, io.SEEK_CUR)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: Can't do nonzero cur-relative seeks
# demonstration that SEEK_SET works treating all characters as one unit
>>> f.seek(2, io.SEEK_SET)
2
>>> f.read()
'st'
As far as I know this is the case in all currently maintained versions of Python 3, since the C-based unicode StringIO implementation was added in 2008. |
|
Date |
User |
Action |
Args |
2020-01-20 02:56:55 | random832 | set | recipients:
+ random832, sanketplus |
2020-01-20 02:56:55 | random832 | set | messageid: <1579489015.49.0.689622990215.issue39365@roundup.psfhosted.org> |
2020-01-20 02:56:55 | random832 | link | issue39365 messages |
2020-01-20 02:56:54 | random832 | create | |
|