diff options
author | Barry Warsaw <barry@python.org> | 2000-11-08 22:19:47 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2000-11-08 22:19:47 (GMT) |
commit | 17bfef5860493a0195c999ab44d4c849660cac30 (patch) | |
tree | 8a806c788ebb86dec1b52b2bda76410a8a99d424 | |
parent | 8a41d20b05600244e344bdacddcb191625062861 (diff) | |
download | cpython-17bfef5860493a0195c999ab44d4c849660cac30.zip cpython-17bfef5860493a0195c999ab44d4c849660cac30.tar.gz cpython-17bfef5860493a0195c999ab44d4c849660cac30.tar.bz2 |
SMTP.connect(): If the socket.connect() raises a socket.error, be sure
to call self.close() to reclaim some file descriptors, the reraise the
exception. Closes SF patch #102185 and SF bug #119833.
-rwxr-xr-x | Lib/smtplib.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/smtplib.py b/Lib/smtplib.py index 6536371..77cd223 100755 --- a/Lib/smtplib.py +++ b/Lib/smtplib.py @@ -214,7 +214,11 @@ class SMTP: if not port: port = SMTP_PORT self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) if self.debuglevel > 0: print 'connect:', (host, port) - self.sock.connect((host, port)) + try: + self.sock.connect((host, port)) + except socket.error: + self.close() + raise (code,msg)=self.getreply() if self.debuglevel >0 : print "connect:", msg return (code,msg) |