diff options
Diffstat (limited to 'Lib/poplib.py')
-rw-r--r-- | Lib/poplib.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/Lib/poplib.py b/Lib/poplib.py index d42d9dd..094aaa1 100644 --- a/Lib/poplib.py +++ b/Lib/poplib.py @@ -259,7 +259,14 @@ class POP3: 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 |