summaryrefslogtreecommitdiffstats
path: root/Lib/poplib.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/poplib.py')
-rw-r--r--Lib/poplib.py18
1 files changed, 2 insertions, 16 deletions
diff --git a/Lib/poplib.py b/Lib/poplib.py
index adf784f..0caed18 100644
--- a/Lib/poplib.py
+++ b/Lib/poplib.py
@@ -76,24 +76,10 @@ class POP3:
"""
- def __init__(self, host, port = POP3_PORT):
+ def __init__(self, host, port=POP3_PORT, timeout=None):
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 as msg:
- if self.sock:
- self.sock.close()
- self.sock = None
- continue
- break
- if not self.sock:
- raise socket.error, msg
+ self.sock = socket.create_connection((host, port), timeout)
self.file = self.sock.makefile('rb')
self._debugging = 0
self.welcome = self._getresp()