summaryrefslogtreecommitdiff
path: root/Lib/imaplib.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/imaplib.py')
-rw-r--r--Lib/imaplib.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/imaplib.py b/Lib/imaplib.py
index 9c38e1c823..8c14728193 100644
--- a/Lib/imaplib.py
+++ b/Lib/imaplib.py
@@ -169,6 +169,17 @@ class IMAP4:
self.open(host, port)
+ try:
+ self._connect()
+ except Exception:
+ try:
+ self.shutdown()
+ except socket.error:
+ pass
+ raise
+
+
+ def _connect(self):
# Create unique tag for this session,
# and compile tagged response matcher.