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 @@ -323,6 +323,10 @@ Extension Modules
323
323
Library
324
324
-------
325
325
326
+ - bpo-30329: imaplib and poplib now catch the Windows socket WSAEINVAL error
327
+ (code 10022) on shutdown(SHUT_RDWR): An invalid operation was attempted.
328
+ This error occurs sometimes on SSL connections.
329
+
326
330
- bpo-29196: Removed previously deprecated in Python 2.4 classes Plist, Dict
327
331
and _InternalDict in the plistlib module. Dict values in the result of
328
332
functions readPlist() and readPlistFromBytes() are now normal dicts. You
You can’t perform that action at this time.
0 commit comments