[Python-checkins] r87777 - python/branches/py3k/Lib/imaplib.py
victor.stinner
python-checkins at python.org
Thu Jan 6 00:01:37 CET 2011
Author: victor.stinner
Date: Thu Jan 6 00:01:37 2011
New Revision: 87777
Log:
imaplib: IMAP4 constructor closes the socket on error
Fix a ResourceWarning(unclosed socket) if an exception is raised in the
constructor after the creation of the socket. Patch written by Nadeem Vawda.
Modified:
python/branches/py3k/Lib/imaplib.py
Modified: python/branches/py3k/Lib/imaplib.py
==============================================================================
--- python/branches/py3k/Lib/imaplib.py (original)
+++ python/branches/py3k/Lib/imaplib.py Thu Jan 6 00:01:37 2011
@@ -169,6 +169,17 @@
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.
More information about the Python-checkins
mailing list