[issue14475] codecs.StreamReader.read behaves differently from regular files

2012-12-07 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

This is obviously a duplicate of issue8260 and issue12446.

--
nosy: +serhiy.storchaka
resolution:  -> duplicate
stage:  -> committed/rejected
status: open -> closed
superseder:  -> When I use codecs.open(...) and f.readline() follow up by 
f.read() return bad result

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14475] codecs.StreamReader.read behaves differently from regular files

2012-05-16 Thread Andrew

Andrew  added the comment:

Just got this behavior, with readlines(), which is unsurprising since it 
internally uses read() as described in the original bug report.

The break on line 468 of codecs.py seems to be the problem, it fixes it if I 
remove this conditional locally.

http://hg.python.org/cpython/file/f6a207d86154/Lib/codecs.py#l466

I may be overlooking something, but I would assume this should be checking if 
the character buffer extends to the EOF of the underlaying stream at this point?

As stated before can be reproduced by:
f = codecs.open(...)
f.read()
f.readlines()

--
nosy: +Andrew.S

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14475] codecs.StreamReader.read behaves differently from regular files

2012-04-02 Thread STINNER Victor

STINNER Victor  added the comment:

Oh, yet another bug in in codecs.StreamReader. I should add it to the PEP :-)
http://www.python.org/dev/peps/pep-0400/

Use io.TextIOWrapper (open) instead of codecs.StreamReader (codecs.open), it's 
bugfree :-)

--
nosy: +haypo

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14475] codecs.StreamReader.read behaves differently from regular files

2012-04-02 Thread Mikko Rasa

New submission from Mikko Rasa :

For regular files, a read() call without arguments will read until EOF.  
codecs.StreamReader does its own buffering, and if there are characters in the 
buffer, a read() call will be satisfied from the buffer without an attempt to 
read the rest of the file.  This discrepancy causes certain code that worked 
with regular open() fail if codecs.open() is substituted.

The easiest way to reproduce this is to first call readline() and then read().  
Since readline() can't know how many characters are on the line, it will almost 
always leave some characters in the buffer, triggering the problem with read().

--
messages: 157355
nosy: tdb
priority: normal
severity: normal
status: open
title: codecs.StreamReader.read behaves differently from regular files
type: behavior
versions: Python 2.6, Python 2.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com