diff options
Diffstat (limited to 'Lib/poplib.py')
-rw-r--r-- | Lib/poplib.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Lib/poplib.py b/Lib/poplib.py index cae6950..6bcfa5c 100644 --- a/Lib/poplib.py +++ b/Lib/poplib.py @@ -288,9 +288,12 @@ class POP3: if sock is not None: try: sock.shutdown(socket.SHUT_RDWR) - except OSError as e: - # The server might already have closed the connection - if e.errno != errno.ENOTCONN: + except OSError as exc: + # The server might already have closed the connection. + # On Windows, this may result in WSAEINVAL (error 10022): + # An invalid operation was attempted. + if (exc.errno != errno.ENOTCONN + and getattr(exc, 'winerror', 0) != 10022): raise finally: sock.close() |