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: test_ssl logs a traceback
Type: Stage: resolved
Components: Tests Versions: Python 3.7, Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Mariatta, alex, christian.heimes, dstufft, janssen, martin.panter, pitrou, vstinner
Priority: normal Keywords:

Created on 2017-09-01 14:39 by vstinner, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 3360 merged christian.heimes, 2017-09-05 21:25
PR 3369 merged python-dev, 2017-09-05 23:37
Messages (9)
msg301107 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-09-01 14:39
It would be nice to not log such traceback:

haypo@selma$ ./python -m test test_ssl -m test.test_ssl.ThreadedTests.test_echo
Run tests sequentially
0:00:00 load avg: 0.69 [1/1] test_ssl
Exception in thread Thread-16:
Traceback (most recent call last):
  File "/home/haypo/prog/python/master/Lib/threading.py", line 917, in _bootstrap_inner
    self.run()
  File "/home/haypo/prog/python/master/Lib/test/test_ssl.py", line 1936, in run
    if not self.wrap_conn():
  File "/home/haypo/prog/python/master/Lib/test/test_ssl.py", line 1881, in wrap_conn
    self.sock, server_side=True)
  File "/home/haypo/prog/python/master/Lib/ssl.py", line 401, in wrap_socket
    _context=self, _session=session)
  File "/home/haypo/prog/python/master/Lib/ssl.py", line 808, in __init__
    self.do_handshake()
  File "/home/haypo/prog/python/master/Lib/ssl.py", line 1061, in do_handshake
    self._sslobj.do_handshake()
  File "/home/haypo/prog/python/master/Lib/ssl.py", line 683, in do_handshake
    self._sslobj.do_handshake()
OSError: [Errno 0] Error

1 test OK.

Total duration: 205 ms
Tests result: SUCCESS
msg301108 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-09-01 14:40
Python 2.7 doesn't seem to be affected.
msg301110 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2017-09-01 14:47
I don't get such traceback here (Ubuntu 16.04, OpenSSL 1.0.2g).
msg301119 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-09-01 15:05
I'm running Fedora 26:

haypo@selma$ ./python -m test.pythoninfo|grep -E 'ssl|platform'
platform.architecture: 32bit ELF
platform.platform: Linux-4.12.5-300.fc26.x86_64-x86_64-with-fedora-26-Twenty_Six
platform.python_implementation: CPython
ssl.HAS_SNI: True
ssl.OPENSSL_VERSION: OpenSSL 1.1.0f-fips  25 May 2017
ssl.OPENSSL_VERSION_INFO: (1, 1, 0, 6, 15)
ssl.OP_ALL: -0x7fffffac
ssl.OP_NO_TLSv1_1: 0x10000000
sys.platform: linux
msg301209 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2017-09-04 06:06
Not sure if you just want to hide the presence of the exception and traceback. But regarding the exception itself (OSError with errno 0), this is not ideal. From memory, you tend to get this when the connection is shut down insecurely at the TCP level. A better exception would be SSLEOFError. Similar report in Issue 31122 (same wrap_socket → do_handshake chain). Probably also relevant: Issue 10808.
msg301375 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2017-09-05 21:07
The error occurs in the test case that uses a PROTOCOL_TLS_SERVER context for both client and server context. In that case, OpenSSL wrap_socket() fails internally and OpenSSL raises an OSError with errno 0.

Simple fix: catch OSError in the client thread and fail the test appropriately.
msg301403 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2017-09-05 23:37
New changeset 305e56c27afce605e5d2f71903a966cf0bb95038 by Christian Heimes in branch 'master':
bpo-31320: No traceback to sys.stderr in test_ssl (#3360)
https://github.com/python/cpython/commit/305e56c27afce605e5d2f71903a966cf0bb95038
msg301425 - (view) Author: Mariatta (Mariatta) * (Python committer) Date: 2017-09-06 01:11
New changeset c506403faf8dbfc8baf4212e8e2aedb7268acb5e by Mariatta (Miss Islington (bot)) in branch '3.6':
[3.6] bpo-31320: No traceback to sys.stderr in test_ssl (GH-3360) (GH-3369)
https://github.com/python/cpython/commit/c506403faf8dbfc8baf4212e8e2aedb7268acb5e
msg302020 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-09-13 00:54
Thanks for the fix Christian.
History
Date User Action Args
2022-04-11 14:58:51adminsetgithub: 75501
2017-09-13 00:54:27vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg302020

stage: resolved
2017-09-06 01:11:33Mariattasetnosy: + Mariatta
messages: + msg301425
2017-09-05 23:37:19python-devsetpull_requests: + pull_request3378
2017-09-05 23:37:12christian.heimessetmessages: + msg301403
2017-09-05 21:25:36christian.heimessetpull_requests: + pull_request3373
2017-09-05 21:07:27christian.heimessetmessages: + msg301375
2017-09-04 06:06:32martin.pantersetnosy: + martin.panter
messages: + msg301209
2017-09-01 15:05:03vstinnersetmessages: + msg301119
2017-09-01 14:47:17pitrousetnosy: + pitrou
messages: + msg301110
2017-09-01 14:40:23vstinnersetmessages: + msg301108
versions: + Python 3.6
2017-09-01 14:39:37vstinnercreate