mirror of
https://github.com/python/cpython.git
synced 2025-08-22 09:45:06 +00:00
bpo-30329: Catch Windows error 10022 on shutdown() (#1538)
Catch the Windows socket WSAEINVAL error (code 10022) in imaplib and poplib on shutdown(SHUT_RDWR): An invalid operation was attempted This error occurs sometimes on SSL connections.
This commit is contained in:
parent
edef358ed6
commit
83a2c28798
3 changed files with 16 additions and 6 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue