diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2001-10-07 08:53:32 +0000 |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2001-10-07 08:53:32 +0000 |
commit | 322c0d187d834013d70ffdb0f7f1b6f72eef6443 (patch) | |
tree | ca8bbe6526e9f3c88b6311691e7936bfdc0480b0 /Lib/poplib.py | |
parent | fb163784ab8ec237fdc3bffd018efe653ae07a1d (diff) | |
download | cpython-git-322c0d187d834013d70ffdb0f7f1b6f72eef6443.tar.gz |
Only close sockets if they have been created. Reported by Blake Winton.
Diffstat (limited to 'Lib/poplib.py')
-rw-r--r-- | Lib/poplib.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/poplib.py b/Lib/poplib.py index 98b81ce620..cb3e004640 100644 --- a/Lib/poplib.py +++ b/Lib/poplib.py @@ -76,13 +76,15 @@ class POP3: self.host = host self.port = port msg = "getaddrinfo returns an empty list" + self.sock = None for res in socket.getaddrinfo(self.host, self.port, 0, socket.SOCK_STREAM): af, socktype, proto, canonname, sa = res try: self.sock = socket.socket(af, socktype, proto) self.sock.connect(sa) except socket.error, msg: - self.sock.close() + if self.sock: + self.sock.close() self.sock = None continue break |