This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author martin.panter
Recipients martin.panter
Date 2015-09-20.06:15:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1442729712.98.0.451356431809.issue25190@psf.upfronthosting.co.za>
In-reply-to
Content
This follows from Issue 12922. When no newline translation is being done, it would be useful to define the seek() offset as the code point offset into the underlying string, allowing stuff like:

s = StringIO()
print("line", file=s)  # Some inflexible API with an unwanted newline
s.seek(-1, SEEK_CUR)  # Undo the trailing newline
s.truncate()

In general, relative seeks are not allowed for text streams, and absolute offsets have arbitrary values. But when no encoding is actually going on, these restrictions are annoying.

I guess the biggest problem is what to do when newline translation is enabled. But I think this is a rarely-used feature of StringIO. I suggest to say that offsets in that case remain arbitrary, and let the code do whatever it happens to do (probably jumping to the wrong character, chopping CRLFs in half, etc, as long as it won’t crash).
History
Date User Action Args
2015-09-20 06:15:13martin.pantersetrecipients: + martin.panter
2015-09-20 06:15:12martin.pantersetmessageid: <1442729712.98.0.451356431809.issue25190@psf.upfronthosting.co.za>
2015-09-20 06:15:12martin.panterlinkissue25190 messages
2015-09-20 06:15:12martin.pantercreate