[issue13721] ssl.wrap_socket on a connected but failed connection succeeds and .peer_certificate gives AttributeError

Antoine Pitrou report at bugs.python.org
Mon Apr 29 21:43:22 CEST 2013


Antoine Pitrou added the comment:

Ok, so this is a slightly annoying issue, but which isn't critical since there's a workaround (catch the AttributeError). Therefore I'm inclined not to change the behaviour in a bugfix release, for fear of regressions for people who are used to the workaround.

In 3.4, it makes sense to improve behaviour. I would propose the following: when self._sslobj is None, call getpeername() on the underlying socket, and let it raise, so that the user gets an appropriate exception for the situation (ENOTCONN mostly, but who knows?). If getpeername() doesn't raise, raise a ValueError instead (since it's akin to calling read() or fileno() on a closed file).

What do you think?

----------
versions: +Python 3.4 -Python 2.7, Python 3.2, Python 3.3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13721>
_______________________________________


More information about the Python-bugs-list mailing list