question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: wrap_socket() missing 1 required positional argument: 'sock'

See original GitHub issue

I am getting this error since the release of 0.9.5. This happens on Python 2.7, 3.4, 3.5 and 3.6.

Here’s the stack-trace:

Traceback (most recent call last):
  File "/home/travis/build/GetStream/stream-django/.eggs/httpretty-0.9.5-py3.6.egg/httpretty/core.py", line 1636, in wrapper
    return test(*args, **kw)
  File "/home/travis/build/GetStream/stream-django/stream_django/tests/test_app/tests/test_manager.py", line 48, in test_unfollow_user
    feed_manager.unfollow_user(1, 2)
  File "/home/travis/build/GetStream/stream-django/stream_django/managers.py", line 49, in unfollow_user
    feed.unfollow(target_feed.slug, target_feed.user_id)
  File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/stream/feed.py", line 166, in unfollow
    response = self.client.delete(url, signature=token, params=params)
  File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/stream/client.py", line 271, in delete
    return self._make_request(self.session.delete, *args, **kwargs)
  File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/stream/client.py", line 210, in _make_request
    params=default_params, timeout=self.timeout)
  File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/requests/sessions.py", line 591, in delete
    return self.request('DELETE', url, **kwargs)
  File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/requests/sessions.py", line 512, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/requests/sessions.py", line 622, in send
    r = adapter.send(request, **kwargs)
  File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/requests/adapters.py", line 445, in send
    timeout=timeout
  File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/urllib3/connectionpool.py", line 343, in _make_request
    self._validate_conn(conn)
  File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/urllib3/connectionpool.py", line 849, in _validate_conn
    conn.connect()
  File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/urllib3/connection.py", line 356, in connect
    ssl_context=context)
  File "/home/travis/build/GetStream/stream-django/.eggs/httpretty-0.9.5-py3.6.egg/httpretty/core.py", line 600, in fake_wrap_socket
    return orig_wrap_socket_fn(*args, **kw)
  File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/urllib3/util/ssl_.py", line 359, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "/home/travis/build/GetStream/stream-django/.eggs/httpretty-0.9.5-py3.6.egg/httpretty/core.py", line 600, in fake_wrap_socket
    return orig_wrap_socket_fn(*args, **kw)
TypeError: wrap_socket() missing 1 required positional argument: 'sock'

This is happening on a public Github project during Travis (https://travis-ci.org/GetStream/stream-django/builds).

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:7
  • Comments:12

github_iconTop GitHub Comments

5reactions
DanielSCrouchcommented, Jul 21, 2019

Any progress?

1reaction
kalkehcoisacommented, Sep 7, 2018

I stumbled on this error as well. It happens in this method:

def fake_wrap_socket(orig_wrap_socket_fn, *args, **kw):
    """drop-in replacement for py:func:`ssl.wrap_socket`
    """
    server_hostname = kw.get('server_hostname')
    if server_hostname is not None:
        matcher = httpretty.match_https_hostname(server_hostname)
        if matcher is None:
                return orig_wrap_socket_fn(*args, **kw)
    if 'sock' in kw:
        return kw['sock']
    else:
        return args[0]

Checking around, I found out that the problem comes from line 1491:

ssl.SSLContext.wrap_socket = partial(fake_wrap_socket, old_sslcontext_wrap_socket)

ssl.SSLContext.wrap_socket is a class method and has a self param that partial ignores completely. It should use functools.partialmethod and apply the instance ssl.SSLContext properly around. As it is, the call on line 600 is attributing the fake sock and causing the error. I tried fixing this way. Sock missing was solved. BUT, the lib got stuck. It didn’t break, nor answered a thing.

So, there must be something more here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

wrap_socket() missing 1 required positional argument: 'sock'
I am getting this error since the release of 0.9.5 . This happens on Python 2.7, 3.4, 3.5 and 3.6. Here's the stack-trace:...
Read more >
TypeError: brodcast() missing 1 required positional argument ...
I'm creating a simple chat server and I keep getting this error. Traceback (most recent call last): File "C:\Users\OneDrive\Desktop\Py Files\ ...
Read more >
wrap_socket() missing 1 required positional argument: 'sock'
We have a "Blender Farm" with a master and a few slaves. Now we try to use SSL. I configured the path of...
Read more >
python - Problem using NetworkRender and SSL
I think I found the solution by myself. There are missing argumets in the python-script netrender/master.py.
Read more >
Release Notes — HTTPretty 1.1.4 documentation
Fix TypeError: wrap_socket() missing 1 required positional argument: 'sock' (#393). Merge pull request #364. Merge pull request #371.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found