Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit83a2c28

Browse files
authored
bpo-30329: Catch Windows error 10022 on shutdown() (#1538)
Catch the Windows socket WSAEINVAL error (code 10022) in imaplib andpoplib on shutdown(SHUT_RDWR): An invalid operation was attemptedThis error occurs sometimes on SSL connections.
1 parentedef358 commit83a2c28

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

‎Lib/imaplib.py‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,12 @@ def shutdown(self):
318318
self.file.close()
319319
try:
320320
self.sock.shutdown(socket.SHUT_RDWR)
321-
exceptOSErrorase:
322-
# The server might already have closed the connection
323-
ife.errno!=errno.ENOTCONN:
321+
exceptOSErrorasexc:
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+
andgetattr(exc,'winerror',0)!=10022):
324327
raise
325328
finally:
326329
self.sock.close()

‎Lib/poplib.py‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,12 @@ def close(self):
288288
ifsockisnotNone:
289289
try:
290290
sock.shutdown(socket.SHUT_RDWR)
291-
exceptOSErrorase:
292-
# The server might already have closed the connection
293-
ife.errno!=errno.ENOTCONN:
291+
exceptOSErrorasexc:
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+
andgetattr(exc,'winerror',0)!=10022):
294297
raise
295298
finally:
296299
sock.close()

‎Misc/NEWS‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,10 @@ Extension Modules
323323
Library
324324
-------
325325

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+
326330
- bpo-29196: Removed previously deprecated in Python 2.4 classes Plist, Dict
327331
and _InternalDict in the plistlib module. Dict values in the result of
328332
functions readPlist() and readPlistFromBytes() are now normal dicts. You

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp