[issue3910] 2.6 regression in socket.ssl method

jan matejek report at bugs.python.org
Fri Sep 19 19:49:36 CEST 2008


New submission from jan matejek <jmatejek at suse.cz>:

python 2.6's compatibility socket.ssl() method does not handle 'sock'
parameter in the same way.

in 2.5, ssl() looked like this:

def ssl(sock, keyfile=None, certfile=None):
    if hasattr(sock, "_sock"):
        sock = sock._sock
    return _realssl(sock, keyfile, certfile)

in 2.6 the call is handed to ssl.sslwrap_simple, which then blindly does
_ssl.sslwrap(sock._sock, 0, keyfile, certfile, CERT_NONE,
PROTOCOL_SSLv23, None)
instead of checking whether the sock is the socket itself or the socket
object.
This causes code that passes the socket directly to fail with
"AttributeError: '_socket.socket' object has no attribute '_sock'
"

the attached patch fixes the behavior.

----------
components: Library (Lib)
files: bug-sslwrap-simple.patch
keywords: patch
messages: 73434
nosy: matejcik
severity: normal
status: open
title: 2.6 regression in socket.ssl method
type: behavior
versions: Python 2.6
Added file: http://bugs.python.org/file11526/bug-sslwrap-simple.patch

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


More information about the Python-bugs-list mailing list