jayvdb added a comment. Thanks. That is what I expected.
Prior to py2.7.9 's backport of Python 3 ssl <https://hg.python.org/cpython/rev/92163>, aka PEP 466 aka issue 21308 <http://bugs.python.org/issue21308> , `ssl.SSLError` was a normal simple subclass of `socket.error` created using PyErr_NewException. socket.error doesnt have a `__str__` handler, and is a subclass of `IOError`, which is an `EnvironmentError`. https://hg.python.org/cpython/rev/92163#l23.3608 That change introduced a custom `__str__` handler for SSLError. https://hg.python.org/cpython/rev/92163#l23.3617 https://docs.python.org/2/c-api/typeobj.html#c.PyTypeObject.tp_str static PyObject * SSLError_str(PyEnvironmentErrorObject *self) { if (self->strerror != NULL) { Py_INCREF(self->strerror); return self->strerror; } else return PyObject_Str(self->args); } The above simpler this returns strerror, without creating a copy and ignores the other args. So in prior versions, str(SSLError) would be handled by a generic and 'safe' implementation which will construct the string representation using the args, but then in py279 the above assumes that self.strerror is a string. SSLError is not at fault; the strerror passed to the SSLError constructor is expected to be a string. https://docs.python.org/2/library/exceptions.html#exceptions.EnvironmentError https://docs.python.org/3/library/exceptions.html#OSError So, I believe this is a misuse of SSLError, and `raise ssl.SSLError('bad handshake', str(e))` is a good solution. Does that change pass the urllib3 test suite? It appears that this has been fixed in urllib3 https://github.com/shazow/urllib3/commit/e2de9f67f276f5a9c2ca3689ce50eac2c7361f4f but that change has not been syncronised into `requests`. TASK DETAIL https://phabricator.wikimedia.org/T105767 EMAIL PREFERENCES https://phabricator.wikimedia.org/settings/panel/emailpreferences/ To: jayvdb Cc: VcamX, Aklapper, jayvdb, pywikibot-bugs-list, Malyacko, P.Copp _______________________________________________ pywikibot-bugs mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/pywikibot-bugs
