Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot import cheroot.ssl.pyopenssl #6

Closed
mar10 opened this issue Feb 19, 2017 · 8 comments
Closed

Cannot import cheroot.ssl.pyopenssl #6

mar10 opened this issue Feb 19, 2017 · 8 comments
Labels
bug Something is broken help wanted Somebody help us, please!

Comments

@mar10
Copy link
Contributor

mar10 commented Feb 19, 2017

On Windows 10, using Python 3.4, cheroot 5.1 import cheroot.ssl.pyopenssl fails:

(wsgidav34) C:\Prj\git\wsgidav>pip list
cheroot (5.1.0)
defusedxml (0.5.0)
pip (9.0.1)
portend (1.8)
pypiwin32 (219)
pytz (2016.10)
setuptools (18.2)
six (1.10.0)
tempora (1.6.1)
WsgiDAV (2.1.1.dev20170218, c:\prj\git\wsgidav)

(wsgidav34) C:\Prj\git\wsgidav>python
Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cheroot
>>> import cheroot.ssl.pyopenssl
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\prj\env\wsgidav34\lib\site-packages\cheroot\ssl\pyopenssl.py", line 49, in <module>
    class SSL_fileobject(MakeFile):
TypeError: function() argument 1 must be code, not str
>>>

It looks like the problem is in makefile.py, where a function object is assigned to MakeFile

def MakeFile_PY3(sock, mode='r', bufsize=io.DEFAULT_BUFFER_SIZE):
    if 'r' in mode:
        return io.BufferedReader(socket.SocketIO(sock, mode), bufsize)
    else:
        return BufferedWriter(socket.SocketIO(sock, mode), bufsize)

[...]
MakeFile = MakeFile_PY2 if six.PY2 else MakeFile_PY3

and then in pyopenssl.py this function is used as a base class?

from ..makefile import MakeFile

class SSL_fileobject(MakeFile):
    [...]
@webknjaz
Copy link
Member

Seems about right. SSL support isn't ideal. Any ideas how to improve this?

@webknjaz webknjaz added the bug Something is broken label Feb 20, 2017
@webknjaz
Copy link
Member

@mar10
I've tried to craft some tiny patch for this, but realised that it should be a heavy refactoring/redesign of ssl package. I would appreciate any investigation/help/PoC as I cannot put much effort on this now.

@mar10
Copy link
Contributor Author

mar10 commented Apr 24, 2017

Hi Sviatoslav
it is not hi prio on my list either, but I will take a note and may be help out sometime later...

@amrufathy
Copy link

@mar10 @webknjaz Any fix to this yet ? Perhaps a workaround ?

I am on Ubuntu 16.04, Python 3.5.2, Cheroot 5.7.0

@webknjaz
Copy link
Member

webknjaz commented Jul 31, 2017

@amrufathy you should still be able to use built-in SSL adapter or just setup SSL on some higher-level like nginx reverse proxy.
If you have some free time, I'd gladly accept any help fixing this. Currently I'm not focused on SSL module.

@webknjaz
Copy link
Member

JFYI I'm collecting TLS-related tooling for testing in #95

@webknjaz
Copy link
Member

This commit 864ad1c should help

@webknjaz
Copy link
Member

webknjaz commented Sep 3, 2018

The initial problem of not being able to import has been solved. Closing in favor of #113, which is more about fixing the adapter itself now.

@webknjaz webknjaz closed this as completed Sep 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken help wanted Somebody help us, please!
Projects
None yet
Development

No branches or pull requests

3 participants