Title: smtplib.SSLFakeFile hangs forever if "\n" is not encountered
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.6, Python 2.5
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: Nosy List: facundobatista, giampaolo.rodola, gregory.p.smith, jafo, zanella
Priority: normal Keywords: patch

Created on 2008-02-19 19:53 by giampaolo.rodola, last changed 2008-03-20 00:52 by jafo. This issue is now closed.

File name Uploaded Description Edit
smptlib.diff giampaolo.rodola, 2008-02-19 19:53
Messages (3)
msg62569 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2008-02-19 19:53
By looking through the smtplib module code I think I've found a
potential issue in the SSLFakeFile class code since there's a while loop
which is supposed to be stopped only when the "\n" character is encountered:

        def readline(self):
            str = ""
            chr = None
            while chr != "\n":
                chr =
                str += chr
            return str

The patch in attachment just adds a break statement to prevent the while
loop to hang forever in case the "\n" character is never encountered.
msg62805 - (view) Author: Rafael Zanella (zanella) Date: 2008-02-23 20:04
As of 2.6 the smtplib uses the ssl module, until 2.5 it uses _ssl, I
*think* that this issue would bring an Exception on 2.5 while on 2.6
would return a zero length string:
def read(self, len=1024):

        """Read up to LEN bytes and return them.
        Return zero-length string on EOF."""


wich would fulfill the "if not chr:"
msg64135 - (view) Author: Sean Reifschneider (jafo) * (Python committer) Date: 2008-03-20 00:48 says: Return zero-length string on EOF.  So, I'm
going to apply this patch.  Applied in rev 61656.
Date User Action Args
2008-03-20 00:52:18jafosetstatus: open -> closed
resolution: accepted
2008-03-20 00:48:53jafosetpriority: normal
keywords: + patch
messages: + msg64135
nosy: + jafo
2008-02-23 20:04:15zanellasetnosy: + zanella
messages: + msg62805
2008-02-19 19:53:03giampaolo.rodolacreate