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: 2.6 regression in socket.ssl method
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: janssen Nosy List: barry, brett.cannon, gregory.p.smith, janssen, matejcik
Priority: release blocker Keywords: patch

Created on 2008-09-19 17:49 by matejcik, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
bug-sslwrap-simple.patch matejcik, 2008-09-19 17:49
Messages (7)
msg73434 - (view) Author: jan matejek (matejcik) * Date: 2008-09-19 17:49
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.
msg73437 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2008-09-19 19:37
This makes sense and is a trivial compatibility fix.  anyone disagree?
msg73439 - (view) Author: Bill Janssen (janssen) * (Python committer) Date: 2008-09-19 20:13
Looks OK to me.  I think this is a back-port problem from 3.0.

I'll put it in if no one objects.
msg74004 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2008-09-29 04:09
It looks like no one objected. Can you check this in, Bill?
msg74033 - (view) Author: Bill Janssen (janssen) * (Python committer) Date: 2008-09-29 16:53
Will do.
msg74034 - (view) Author: Bill Janssen (janssen) * (Python committer) Date: 2008-09-29 16:59
Maybe not.  test_ssl hangs when I run it "-u all -v".  It's hanging on
testSimpleSSLWrap.  This is on OS X 10.5.5.
msg74039 - (view) Author: Bill Janssen (janssen) * (Python committer) Date: 2008-09-29 18:57
OK, I found the fix.
History
Date User Action Args
2022-04-11 14:56:39adminsetnosy: + barry
github: 48160
2008-09-29 18:57:04janssensetstatus: open -> closed
resolution: fixed
messages: + msg74039
2008-09-29 16:59:04janssensetmessages: + msg74034
2008-09-29 16:53:26janssensetmessages: + msg74033
2008-09-29 04:09:25brett.cannonsetnosy: + brett.cannon
messages: + msg74004
2008-09-19 20:13:46janssensetassignee: janssen
messages: + msg73439
2008-09-19 19:37:14gregory.p.smithsetpriority: release blocker
nosy: + gregory.p.smith, janssen
messages: + msg73437
2008-09-19 17:49:35matejcikcreate