I found this on Lib/email/parser.py, on Parser.parse():

        while True:
            data = fp.read(8192)
            if not data:
                break
# XXX When Guido fixes TextIOWrapper.read() to act just like
            # .readlines(), this...
            feedparser.feed(str(data))
            # ...gets reverted back to
            #feedparser.feed(data)
        return feedparser.close()

  Is that still necessary?

I noticed it while trying to migrate http.client.HTTPMessage away from mimetools (issue 2848). I was having problems when parse() received bytes directly, as they were being converted to 'b"..."' strings.

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)


--
Humberto Diógenes
http://humberto.digi.com.br

_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to