summaryrefslogtreecommitdiffstats
path: root/Lib/imaplib.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2018-08-07 02:38:05 (GMT)
committerBerker Peksag <berker.peksag@gmail.com>2018-08-07 02:38:05 (GMT)
commit671a13a7b6ff1022a6fd868e5842687123ab9fd1 (patch)
tree7e05f2a9eaa5c2e4e0544047189d4c618371c1ea /Lib/imaplib.py
parentb0bf51b32240369ccb736dc32ff82bb96f375402 (diff)
downloadcpython-671a13a7b6ff1022a6fd868e5842687123ab9fd1.zip
cpython-671a13a7b6ff1022a6fd868e5842687123ab9fd1.tar.gz
cpython-671a13a7b6ff1022a6fd868e5842687123ab9fd1.tar.bz2
bpo-18540: Fix EAI_NONAME in imaplib.IMAP4*() (GH-8634)
(cherry picked from commit e4dcbbd7f4ac18d01c0ec85f64ae98b8281ed403) Co-authored-by: Berker Peksag <berker.peksag@gmail.com>
Diffstat (limited to 'Lib/imaplib.py')
-rw-r--r--Lib/imaplib.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/imaplib.py b/Lib/imaplib.py
index 700b19b..b9a01d6 100644
--- a/Lib/imaplib.py
+++ b/Lib/imaplib.py
@@ -282,7 +282,11 @@ class IMAP4:
def _create_socket(self):
- return socket.create_connection((self.host, self.port))
+ # Default value of IMAP4.host is '', but socket.getaddrinfo()
+ # (which is used by socket.create_connection()) expects None
+ # as a default value for host.
+ host = None if not self.host else self.host
+ return socket.create_connection((host, self.port))
def open(self, host = '', port = IMAP4_PORT):
"""Setup connection to remote server on "host:port"