[Patches] [ python-Patches-1379332 ] StreamReader.readline with size reading multiple lines

SourceForge.net noreply at sourceforge.net
Mon Mar 6 23:57:12 CET 2006


Patches item #1379332, was opened at 2005-12-13 09:54
Message generated for change (Comment added) made by doerwalter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1379332&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Library (Lib)
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Matthew Mueller (donut)
Assigned to: Walter Dörwald (doerwalter)
Summary: StreamReader.readline with size reading multiple lines

Initial Comment:
In Python 2.4.2 and trunk, when StreamReader.readline
is used with a size argument, it will eventually
truncate some lines, even if every line is less than
the size.  It works correctly in Python 2.3.5, I
haven't tried other versions.

>>>
f=codecs.getreader('ascii')(StringIO.StringIO("hello\nworld\n"))
>>> f.readline(8)
u'hello\n'
>>> f.readline(8)
u'wo'
>>> f.readline(8)
u'rld\n'

I've attached a patch which fixes this and modifies
test_codecs.py to test this.  I don't know if this is
the best way to fix it, but I didn't want to make
deeper changes to the caching mechanism, being
unfamiliar with this code.

----------------------------------------------------------------------

>Comment By: Walter Dörwald (doerwalter)
Date: 2006-03-06 23:57

Message:
Logged In: YES 
user_id=89016

Checked in another fix as r42872 and r42873: Instead of
calling read() with a chars argument read() reads from the
byte stream, if less then size chars are in the charbuffer.

----------------------------------------------------------------------

Comment By: Georg Brandl (birkenfeld)
Date: 2006-01-20 18:32

Message:
Logged In: YES 
user_id=1188172

Confirmed here (2.5 HEAD, Linux box). Patch works.

Walter?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1379332&group_id=5470


More information about the Patches mailing list