This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: poplib and imaplib should catch "OSError: [WinError 10022] An invalid argument was supplied" on shutdown
Type: Stage: resolved
Components: Library (Lib), SSL, Tests, Windows Versions: Python 3.7, Python 3.6, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: christian.heimes Nosy List: christian.heimes, paul.moore, steve.dower, tim.golden, vstinner, zach.ware
Priority: normal Keywords: buildbot

Created on 2017-05-10 12:26 by vstinner, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 1538 merged vstinner, 2017-05-10 16:51
PR 1620 merged vstinner, 2017-05-16 22:05
PR 1621 merged vstinner, 2017-05-16 22:06
PR 1624 merged vstinner, 2017-05-17 00:16
Messages (8)
msg293411 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-05-10 12:26
See also bpo-30319: test_invalid_authentication()  of test_imaplib: ConnectionResetError: [Errno 54] Connection reset by peer on AMD64 FreeBSD 9.x 3.6.

http://buildbot.python.org/all/builders/AMD64%20Windows8.1%20Non-Debug%203.6/builds/375/steps/test/logs/stdio

test_login_cram_md5 (test.test_imaplib.ThreadedNetworkedTestsSSL) ... creating server
server created
ADDR = ('127.0.0.1', 0)
CLASS = <class 'test.test_imaplib.SecureTCPServer'>
HDLR = <class 'test.test_imaplib.ThreadedNetworkedTests.test_login_cram_md5.<locals>.AuthHandler'>
server running
SENT: b'* OK IMAP4rev1'
GOT: b'PJGL0 CAPABILITY'
SENT: b'* CAPABILITY IMAP4rev1 LOGINDISABLED AUTH=CRAM-MD5'
SENT: b'PJGL0 OK CAPABILITY completed'
GOT: b'PJGL1 AUTHENTICATE CRAM-MD5'
SENT: b'+ PDE4OTYuNjk3MTcwOTUyQHBvc3RvZmZpY2UucmVzdG9uLm1jaS5uZXQ='
GOT: b'dGltIGYxY2E2YmU0NjRiOWVmYTFjY2E2ZmZkNmNmMmQ5ZjMy'
SENT: b'PJGL1 OK CRAM-MD5 successful'
GOT: b'PJGL2 LOGOUT'
SENT: b'* BYE IMAP4ref1 Server logging out'
SENT: b'PJGL2 OK LOGOUT completed'
waiting for server
done
ERROR

======================================================================
ERROR: test_login_cram_md5 (test.test_imaplib.ThreadedNetworkedTestsSSL)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\buildarea\3.6.ware-win81-release\build\lib\test\support\__init__.py", line 2035, in decorator
    return func(*args)
  File "D:\buildarea\3.6.ware-win81-release\build\lib\test\test_imaplib.py", line 796, in test_login_cram_md5
    self.assertEqual(ret, "OK")
  File "D:\buildarea\3.6.ware-win81-release\build\lib\contextlib.py", line 89, in __exit__
    next(self.gen)
  File "D:\buildarea\3.6.ware-win81-release\build\lib\test\test_imaplib.py", line 567, in reaped_pair
    client.logout()
  File "D:\buildarea\3.6.ware-win81-release\build\lib\imaplib.py", line 622, in logout
    self.shutdown()
  File "D:\buildarea\3.6.ware-win81-release\build\lib\imaplib.py", line 320, in shutdown
    self.sock.shutdown(socket.SHUT_RDWR)
  File "D:\buildarea\3.6.ware-win81-release\build\lib\ssl.py", line 1040, in shutdown
    socket.shutdown(self, how)
OSError: [WinError 10022] An invalid argument was supplied

----------------------------------------------------------------------
Ran 95 tests in 6.890s

FAILED (errors=1, skipped=4)
test test_imaplib failed
msg293699 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-05-15 09:44
The error code is documented:

https://msdn.microsoft.com/en-us/library/windows/desktop/ms740481(v=vs.85).aspx

WSAEINVAL: The how parameter is not valid, or is not consistent with the socket type. For example, SD_SEND is used with a UNI_RECV socket type.
msg293716 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-05-15 15:33
New changeset 83a2c2879839da2e10037f5e4af1bd1dafbf1a52 by Victor Stinner in branch 'master':
bpo-30329: Catch Windows error 10022 on shutdown() (#1538)
https://github.com/python/cpython/commit/83a2c2879839da2e10037f5e4af1bd1dafbf1a52
msg293814 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-05-16 22:29
New changeset aaa053652556aa4e59cb68f3983a09ced1d1fe2a by Victor Stinner in branch '3.6':
bpo-30329: Catch Windows error 10022 on shutdown() (#1538) (#1620)
https://github.com/python/cpython/commit/aaa053652556aa4e59cb68f3983a09ced1d1fe2a
msg293818 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-05-16 23:02
New changeset c9ba45d1b71d86321e5422e8a2cbe6e52aaba6f4 by Victor Stinner in branch '3.5':
bpo-30329: Catch Windows error 10022 on shutdown() (#1538) (#1621)
https://github.com/python/cpython/commit/c9ba45d1b71d86321e5422e8a2cbe6e52aaba6f4
msg293830 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-05-17 00:38
New changeset 800e4b7ad6b6f86c17408429852dfb47493d366e by Victor Stinner in branch '2.7':
bpo-30329: Catch Windows error 10022 on shutdown() (#1538) (#1624)
https://github.com/python/cpython/commit/800e4b7ad6b6f86c17408429852dfb47493d366e
msg296967 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-06-26 23:01
The bug should now be catched.
msg296970 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-06-26 23:06
> The bug should now be catched.

Oops, I wanted to write: "should now be fixed", sorry!
History
Date User Action Args
2022-04-11 14:58:46adminsetgithub: 74514
2017-06-26 23:06:53vstinnersetmessages: + msg296970
2017-06-26 23:01:05vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg296967

stage: resolved
2017-05-17 00:38:32vstinnersetmessages: + msg293830
2017-05-17 00:16:30vstinnersetpull_requests: + pull_request1713
2017-05-16 23:02:37vstinnersetmessages: + msg293818
2017-05-16 22:29:43vstinnersetmessages: + msg293814
2017-05-16 22:07:50vstinnersettitle: test_imaplib.test_login_cram_md5(): OSError: [WinError 10022] An invalid argument was supplied on AMD64 Windows8.1 Non-Debug 3.6 -> poplib and imaplib should catch "OSError: [WinError 10022] An invalid argument was supplied" on shutdown
components: + Library (Lib)
versions: + Python 3.5, Python 3.7
2017-05-16 22:06:45vstinnersetpull_requests: + pull_request1710
2017-05-16 22:05:17vstinnersetpull_requests: + pull_request1709
2017-05-15 15:33:48vstinnersetmessages: + msg293716
2017-05-15 09:44:44vstinnersetmessages: + msg293699
2017-05-10 16:51:47vstinnersetpull_requests: + pull_request1637
2017-05-10 12:26:48vstinnercreate