diff options
Diffstat (limited to 'Lib/smtplib.py')
-rwxr-xr-x | Lib/smtplib.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/smtplib.py b/Lib/smtplib.py index 4527a84..8e98608 100755 --- a/Lib/smtplib.py +++ b/Lib/smtplib.py @@ -265,6 +265,7 @@ class SMTP: if not port: port = SMTP_PORT if self.debuglevel > 0: print 'connect:', (host, port) msg = "getaddrinfo returns an empty list" + self.sock = None for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM): af, socktype, proto, canonname, sa = res try: @@ -273,7 +274,8 @@ class SMTP: self.sock.connect(sa) except socket.error, msg: if self.debuglevel > 0: print 'connect fail:', (host, port) - self.sock.close() + if self.sock: + self.sock.close() self.sock = None continue break |