New submission from Antoine Pitrou <pit...@free.fr>:

Or, more precisely, it returns less than the requested number of
characters because characters are counted before translating newlines:

>>> f = io.StringIO("a\r\nb\r\n", newline=None)
>>> f.read(3)
'a\n'

TextIOWrapper gets it right:

>>> g = io.TextIOWrapper(io.BytesIO(b"a\r\nb\r\n"), newline=None)
>>> g.read(3)
'a\nb'

----------
components: Library (Lib)
messages: 82134
nosy: alexandre.vassalotti, pitrou
priority: normal
severity: normal
stage: needs patch
status: open
title: StringIO.read(n) does not enforce requested size in newline mode
type: behavior
versions: Python 2.6, Python 2.7, Python 3.0, Python 3.1

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

Reply via email to