dabeaz / curio

Good Curio!
Other
4.02k stars 241 forks source link

Inconsistent ssl.py module with the same version number #225

Closed CreatCodeBuild closed 6 years ago

CreatCodeBuild commented 7 years ago

In version 0.7 from pip install curio, the CurioSSLContext class under ssl.py module is implemented as:

# Small wrapper class to make sure the wrap_socket() method returns the right type
    class CurioSSLContext(object):

        def __init__(self, context):
            self._context = context

        def __getattr__(self, name):
            return getattr(self._context, name)

        def wrap_socket(self, sock, *args, do_handshake_on_connect=True, **kwargs):
            sock = self._context.wrap_socket(
                sock._socket, *args, do_handshake_on_connect=False, **kwargs)
            csock = Socket(sock)
            csock.do_handshake_on_connect = do_handshake_on_connect
            return csock

        def __setattr__(self, name, value):
            if name == '_context':
                super().__setattr__(name, value)
            else:
                setattr(self._context, name, value)

But in master (not wip), the implementation was

    # Small wrapper class to make sure the wrap_socket() method returns the right type
    class CurioSSLContext(object):

        def __init__(self, context):
            self._context = context

        def __getattr__(self, name):
            return getattr(self._context, name)

        async def wrap_socket(self, sock, *args, do_handshake_on_connect=True, **kwargs):
            sock = self._context.wrap_socket(
                sock._socket, *args, do_handshake_on_connect=False, **kwargs)
            csock = Socket(sock)
            csock.do_handshake_on_connect = do_handshake_on_connect
            if do_handshake_on_connect and sock._connected:
                await csock.do_handshake()
            return csock

        def __setattr__(self, name, value):
            if name == '_context':
                super().__setattr__(name, value)
            else:
                setattr(self._context, name, value)

The API of wrap_socket is different.

My question, which version will be the future stable version? Is the version from pip install curio wip?

Do you always recommend pip install git+https://github.com/dabeaz/curio.git?

dabeaz commented 7 years ago

The version number in GitHub should probably be bumped, but whatever is in GitHub master should considered to be future behavior.

CreatCodeBuild commented 6 years ago

Can you push a new version to pypi? I have a package using Curio as a dependency. The setup.py will always install from pypi. I have not figured out how to make it install from github yet.

dabeaz commented 6 years ago

Will push it today.

iffybug commented 6 years ago

@CreatCodeBuild You could install from git via pip install -e git+https://github.com/dabeaz/curio. see https://stackoverflow.com/questions/11560056/pip-freeze-does-not-show-repository-paths-for-requirements-file

CreatCodeBuild commented 6 years ago

@yifeikong I know out how to force install from GitHub in requirements.txt but still not quite in setup.py