[Python-Dev] unifying read method semantics
Fri, 21 Jun 2002 18:41:25 +1000
A user of imaplib's IMAP4_SSL class has complained that the "read" and
"write" methods don't behave correctly, sometimes omitting to handle all
the requested data. This is a bug - I should have noticed this common
misconception when installing the submitted sub-class into imaplib.
However, this is a common enough gotcha for python programmers that I
wondered if it is worthwhile fixing it once and for all. Ie: mandate
that core python modules providing read/write methods guarantee that
all the data is sent by write() (or exception), and all the requested
data is read() (or exception).
The last time this came up the socketmodule code got a "sendall" method.
However, this doesn't exist in the ssl portion of socketmodule.c.
And while I'm on the topic - please could we always support "readline"
(or "makefile") methods in C modules? Surely the following code now
necessary in imaplib must make CPU-time conscious programmers wince:
"""Read line from remote."""
line = ""
char = self.sslobj.read(1)
line += char
if char == "\n": return line