[Python-3000] TextIOWrapper.read() "fixed"?
Humberto Diogenes
humberto at digi.com.br
Sat Jun 7 05:43:12 CEST 2008
On 06/06/2008, at 15:14, Guido van Rossum wrote:
> On Fri, Jun 6, 2008 at 3:02 AM, Humberto Diogenes <humberto at digi.com.br
> > wrote:
>>
>> Is that still necessary?
>
> I can't tell for sure what Barry meant, but this was introduced in
> August 2007. Since then, a lot has changed in io.py. Why don't you try
> taking it out?
Removing it didn't affect any tests, so I think it can go away now:
http://bugs.python.org/file10537/email.parser-small_fix.patch
>> BTW, is TextIOWrapper+BufferedReader the right solution to read a
>> string
>> from a socket?
>>
>> # In HTTPResponse:
>> - self.msg = HTTPMessage(self.fp, 0)
>> + parser = email.parser.HeaderParser(_class=HTTPMessage)
>> + fp = io.TextIOWrapper(io.BufferedReader(self.fp), 'latin1')
>> + self.msg = parser.parse(fp)
>
> Probably. This is what the socket class's own makefile() method does.
> Read all about it in socket.py.
I can't use makefile() there, so I believe I did the Right Thing™.
Thanks for the tip, Guido! socket.makefile really is a great demo. :)
--
Humberto Diógenes
http://humberto.digi.com.br
More information about the Python-3000
mailing list