classification
Title: Python 3 ssl module can't use a fileno to create a SSLSocket
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.5
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Cannot create ssl.SSLSocket without existing socket
View: 27629
Assigned To: Nosy List: SenBin Yu, berker.peksag
Priority: normal Keywords:

Created on 2016-09-07 03:25 by SenBin Yu, last changed 2016-09-07 12:37 by berker.peksag. This issue is now closed.

Files
File name Uploaded Description Edit
SSLSocket_sock.png SenBin Yu, 2016-09-07 03:25 SSLSocket socket __init__ branch conditions snapshot
Messages (6)
msg274740 - (view) Author: SenBin Yu (SenBin Yu) Date: 2016-09-07 03:25
In the SSLSocket __init__ function, it's ok to do a socket type check with argument sock.But meanwhile the sock argument can't be None, which make the SSLSocket socket __init__ way meaningless.Although there are three branch conditions as argument sock, fileno and other.
msg274798 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-09-07 11:34
Thanks for the report. This looks like a duplicate of issue 27629. Please provide a reproducer if it's different problem than issue 27629.
msg274801 - (view) Author: SenBin Yu (SenBin Yu) Date: 2016-09-07 11:51
The issue 27629 describe creating a SSLSocket only with server_hostname argument.But what i said is that we can't creating a SSLSocket with fileno argument from a existing socket.I'm strange about this code design that meaningless branch conditions exists.
msg274803 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-09-07 12:00
Did you look at the patch? It adds the following test case:

+        s = socket.socket()
+        sfd = s.fileno()
+        # Create secure socket from fileno
+        ss = ssl.SSLSocket(fileno=sfd)
+        self.assertTrue(ss.fileno() == sfd)

Isn't that what you want to achieve?
msg274804 - (view) Author: SenBin Yu (SenBin Yu) Date: 2016-09-07 12:17
Yes, the giving code is what i desiere and shoud be supported. Sorry, i haven't see the patch file.And the next release will include this patch?
msg274805 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-09-07 12:37
Great, closing this then.

> And the next release will include this patch?

Christian (one of our SSL module maintainers) just reviewed the patch so the next step is to address his review comments and upload a new patch. If you don't see any movement from nemunaire (the original author of the patch) after a week or so, you can update the patch yourself (it would help to get it fixed sooner.)
History
Date User Action Args
2016-09-07 12:37:24berker.peksagsetstatus: open -> closed
resolution: duplicate
messages: + msg274805
2016-09-07 12:17:06SenBin Yusetmessages: + msg274804
2016-09-07 12:00:19berker.peksagsetmessages: + msg274803
2016-09-07 11:51:30SenBin Yusetstatus: closed -> open
resolution: duplicate -> (no value)
messages: + msg274801
2016-09-07 11:34:22berker.peksagsetstatus: open -> closed

superseder: Cannot create ssl.SSLSocket without existing socket

nosy: + berker.peksag
messages: + msg274798
resolution: duplicate
stage: resolved
2016-09-07 03:25:51SenBin Yucreate