File tree Expand file tree Collapse file tree 3 files changed +16
-6
lines changed
Expand file tree Collapse file tree 3 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -310,9 +310,12 @@ def shutdown(self):
310310 self .file .close ()
311311 try :
312312 self .sock .shutdown (socket .SHUT_RDWR )
313- except OSError as e :
314- # The server might already have closed the connection
315- if e .errno != errno .ENOTCONN :
313+ except OSError as exc :
314+ # The server might already have closed the connection.
315+ # On Windows, this may result in WSAEINVAL (error 10022):
316+ # An invalid operation was attempted.
317+ if (exc .errno != errno .ENOTCONN
318+ and getattr (exc , 'winerror' , 0 ) != 10022 ):
316319 raise
317320 finally :
318321 self .sock .close ()
Original file line number Diff line number Diff line change @@ -288,9 +288,12 @@ def close(self):
288288 if sock is not None :
289289 try :
290290 sock .shutdown (socket .SHUT_RDWR )
291- except OSError as e :
292- # The server might already have closed the connection
293- if e .errno != errno .ENOTCONN :
291+ except OSError as exc :
292+ # The server might already have closed the connection.
293+ # On Windows, this may result in WSAEINVAL (error 10022):
294+ # An invalid operation was attempted.
295+ if (exc .errno != errno .ENOTCONN
296+ and getattr (exc , 'winerror' , 0 ) != 10022 ):
294297 raise
295298 finally :
296299 sock .close ()
Original file line number Diff line number Diff line change @@ -49,6 +49,10 @@ Extension Modules
4949Library
5050-------
5151
52+ - bpo-30329: imaplib and poplib now catch the Windows socket WSAEINVAL error
53+ (code 10022) on shutdown(SHUT_RDWR): An invalid operation was attempted.
54+ This error occurs sometimes on SSL connections.
55+
5256- bpo-30375: Warnings emitted when compile a regular expression now always
5357 point to the line in the user code. Previously they could point into inners
5458 of the re module if emitted from inside of groups or conditionals.
You can’t perform that action at this time.
0 commit comments