mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
Only close sockets if they have been created. Reported by Blake Winton.
This commit is contained in:
parent
fb163784ab
commit
322c0d187d
5 changed files with 15 additions and 6 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue