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 @@ -318,9 +318,12 @@ def shutdown(self):
318
318
self .file .close ()
319
319
try :
320
320
self .sock .shutdown (socket .SHUT_RDWR )
321
- except OSError as e :
322
- # The server might already have closed the connection
323
- if e .errno != errno .ENOTCONN :
321
+ except OSError as exc :
322
+ # The server might already have closed the connection.
323
+ # On Windows, this may result in WSAEINVAL (error 10022):
324
+ # An invalid operation was attempted.
325
+ if (exc .errno != errno .ENOTCONN
326
+ and getattr (exc , 'winerror' , 0 ) != 10022 ):
324
327
raise
325
328
finally :
326
329
self .sock .close ()
Original file line number Diff line number Diff line change @@ -288,9 +288,12 @@ def close(self):
288
288
if sock is not None :
289
289
try :
290
290
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 ):
294
297
raise
295
298
finally :
296
299
sock .close ()
Original file line number Diff line number Diff line change @@ -36,6 +36,10 @@ Core and Builtins
36
36
Library
37
37
-------
38
38
39
+ - bpo-30329: imaplib and poplib now catch the Windows socket WSAEINVAL error
40
+ (code 10022) on shutdown(SHUT_RDWR): An invalid operation was attempted.
41
+ This error occurs sometimes on SSL connections.
42
+
39
43
- bpo-30375: Warnings emitted when compile a regular expression now always
40
44
point to the line in the user code. Previously they could point into inners
41
45
of the re module if emitted from inside of groups or conditionals.
You can’t perform that action at this time.
0 commit comments