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):
310
310
self .file .close ()
311
311
try :
312
312
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 ):
316
319
raise
317
320
finally :
318
321
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 @@ -49,6 +49,10 @@ Extension Modules
49
49
Library
50
50
-------
51
51
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
+
52
56
- bpo-30375: Warnings emitted when compile a regular expression now always
53
57
point to the line in the user code. Previously they could point into inners
54
58
of the re module if emitted from inside of groups or conditionals.
You can’t perform that action at this time.
0 commit comments