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: def readline(self): """Read line from remote.""" line = "" while 1: char = self.sslobj.read(1) line += char if char == "\n": return line :-) Piers Lauder.
Piers Lauder
And while I'm on the topic - please could we always support "readline" (or "makefile") methods in C modules?
I don't think this is feasiable.
Surely the following code now necessary in imaplib must make CPU-time conscious programmers wince:
def readline(self): """Read line from remote.""" line = "" while 1: char = self.sslobj.read(1) line += char if char == "\n": return line
Moving this algorithm to another location won't essentially change CPU consumption... Regards, Martin
participants (2)
-
martin@v.loewis.de
-
Piers Lauder