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

Comments

Projects
None yet
3 participants
@mar10
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

This comment has been minimized.

Member

webknjaz commented Feb 20, 2017

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

@webknjaz webknjaz added the bug label Feb 20, 2017

@webknjaz

This comment has been minimized.

Member

webknjaz commented Apr 23, 2017

@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

This comment has been minimized.

Contributor

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

This comment has been minimized.

amrufathy commented Jul 31, 2017

@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

This comment has been minimized.

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

This comment has been minimized.

Member

webknjaz commented Jun 20, 2018

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

@webknjaz

This comment has been minimized.

Member

webknjaz commented Aug 29, 2018

This commit 864ad1c should help

@webknjaz

This comment has been minimized.

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 Sep 3, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment