[Python-checkins] cpython: Issue #4473: Ensure the socket is shutdown cleanly in POP3.close().
antoine.pitrou
python-checkins at python.org
Fri Nov 23 20:15:07 CET 2012
http://hg.python.org/cpython/rev/79e33578dc05
changeset: 80573:79e33578dc05
user: Antoine Pitrou <solipsis at pitrou.net>
date: Fri Nov 23 20:04:45 2012 +0100
summary:
Issue #4473: Ensure the socket is shutdown cleanly in POP3.close().
Patch by Lorenzo Catucci.
files:
Lib/poplib.py | 9 ++++++++-
Misc/NEWS | 3 +++
2 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/Lib/poplib.py b/Lib/poplib.py
--- a/Lib/poplib.py
+++ b/Lib/poplib.py
@@ -259,7 +259,14 @@
if self.file is not None:
self.file.close()
if self.sock is not None:
- self.sock.close()
+ try:
+ self.sock.shutdown(socket.SHUT_RDWR)
+ except socket.error as e:
+ # The server might already have closed the connection
+ if e.errno != errno.ENOTCONN:
+ raise
+ finally:
+ self.sock.close()
self.file = self.sock = None
#__del__ = quit
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -138,6 +138,9 @@
Library
-------
+- Issue #4473: Ensure the socket is shutdown cleanly in POP3.close().
+ Patch by Lorenzo Catucci.
+
- Issue #16522: added FAIL_FAST flag to doctest.
- Issue #15627: Add the importlib.abc.SourceLoader.compile_source() method.
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list