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

Tests fail with PySocks-1.7.1 #170

Open
mgorny opened this issue May 27, 2020 · 7 comments · Fixed by #202
Open

Tests fail with PySocks-1.7.1 #170

mgorny opened this issue May 27, 2020 · 7 comments · Fixed by #202

Comments

@mgorny
Copy link
Contributor

mgorny commented May 27, 2020

___________________________________________ test_server_not_found_error_is_raised_for_invalid_hostname ____________________________________________
/usr/lib/python3.8/site-packages/socks.py:787: in connect
    super(socksocket, self).connect(proxy_addr)
/usr/lib/python3.8/site-packages/mock/mock.py:1092: in __call__
    return _mock_self._mock_call(*args, **kwargs)
/usr/lib/python3.8/site-packages/mock/mock.py:1149: in _mock_call
    result = effect(*args, **kwargs)
tests/test_proxy.py:21: in _raise_name_not_known_error
    raise socket.gaierror(socket.EAI_NONAME, "Name or service not known")
E   socket.gaierror: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:
/usr/lib/python3.8/site-packages/httplib2/__init__.py:1557: in _conn_request
    conn.connect()
/usr/lib/python3.8/site-packages/httplib2/__init__.py:1236: in connect
    raise socket_err
/usr/lib/python3.8/site-packages/httplib2/__init__.py:1210: in connect
    self.sock.connect((self.host, self.port) + sa[2:])
/usr/lib/python3.8/site-packages/socks.py:47: in wrapper
    return function(*args, **kwargs)
/usr/lib/python3.8/site-packages/socks.py:800: in connect
    raise ProxyConnectionError(msg, error)
E   socks.ProxyConnectionError: Error connecting to HTTP proxy 255.255.255.255:8001: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:
tests/test_proxy.py:116: in test_server_not_found_error_is_raised_for_invalid_hostname
    http.request("http://invalid.hostname.foo.bar/", "GET")
/usr/lib/python3.8/site-packages/httplib2/__init__.py:1985: in request
    (response, content) = self._request(
/usr/lib/python3.8/site-packages/httplib2/__init__.py:1650: in _request
    (response, content) = self._conn_request(
/usr/lib/python3.8/site-packages/httplib2/__init__.py:1567: in _conn_request
    e.args[0].errno if isinstance(e.args[0], socket.error) else e.errno
E   IndexError: tuple index out of range
________________________________________________________________ test_socks5_auth _________________________________________________________________
tests/test_proxy.py:174: in test_socks5_auth
    with tests.assert_raises(httplib2.socks.Socks5AuthError):
E   AttributeError: module 'socks' has no attribute 'Socks5AuthError'
@temoto
Copy link
Member

temoto commented May 27, 2020

Thanks. Do you have to run tests with pysocks available in packages? httplib2 currently vendors this module but defaults to using external package if available. We should switch to just depending on external package #121 but wasn't done yet.

@mgorny
Copy link
Contributor Author

mgorny commented May 27, 2020

If you're asking whether this is high priority for us, then no. I've just skipped these two tests for now.

@temoto
Copy link
Member

temoto commented May 27, 2020

I meant that running tests in isolated virtualenv without pysocks would solve the issue too. Good to know it's not blocking.

@mgorny
Copy link
Contributor Author

mgorny commented May 27, 2020

We don't use virtualenv because it doesn't reliably indicate whether the package's actually going to work correctly in the production environment along with other packages. There are many packages that break in presence of others, and it's better to know that before installing them.

ivanyu added a commit to ivanyu/httplib2 that referenced this issue Sep 25, 2021
In the presence of PySocks, httplib2 falls back on it instead of its own bundled `socks.py`. However, exception `ProxyConnectionError` produced by PySocks is a bit different that expected, it lacks `args`. An attempt to extract `errno` from it fails with `IndexError: tuple index out of range` (see httplib2#170). The patch addresses this.
@ivanyu
Copy link
Contributor

ivanyu commented Sep 25, 2021

Would you consider a patch like #202?

ivanyu added a commit to ivanyu/httplib2 that referenced this issue Sep 25, 2021
In the presence of PySocks, httplib2 falls back on it instead of its own bundled `socks.py`. However, exception `ProxyConnectionError` produced by PySocks is a bit different that expected, it lacks `args`. An attempt to extract `errno` from it fails with `IndexError: tuple index out of range` (see httplib2#170). The patch addresses this.
ivanyu added a commit to ivanyu/httplib2 that referenced this issue Sep 25, 2021
In the presence of PySocks, httplib2 falls back on it instead of its own bundled `socks.py`. However, exception `ProxyConnectionError` produced by PySocks is a bit different that expected, it lacks `args`. An attempt to extract `errno` from it fails with `IndexError: tuple index out of range` (see httplib2#170). The patch addresses this.
ivanyu added a commit to ivanyu/httplib2 that referenced this issue Sep 25, 2021
In the presence of PySocks, httplib2 falls back on it instead of its own bundled `socks.py`. However, exception `ProxyConnectionError` produced by PySocks is a bit different that expected, it lacks `args`. An attempt to extract `errno` from it fails with `IndexError: tuple index out of range` (see httplib2#170). The patch addresses this.
ivanyu added a commit to ivanyu/httplib2 that referenced this issue Oct 3, 2021
In the presence of PySocks, httplib2 falls back on it instead of its own bundled `socks.py`. However, exception `ProxyConnectionError` produced by PySocks is a bit different that expected, it lacks `args`. An attempt to extract `errno` from it fails with `IndexError: tuple index out of range` (see httplib2#170). The patch addresses this.
temoto pushed a commit to ivanyu/httplib2 that referenced this issue Oct 11, 2021
In the presence of PySocks, httplib2 falls back on it instead of its own bundled `socks.py`. However, exception `ProxyConnectionError` produced by PySocks is a bit different that expected, it lacks `args`. An attempt to extract `errno` from it fails with `IndexError: tuple index out of range` (see httplib2#170). The patch addresses this.
temoto pushed a commit to ivanyu/httplib2 that referenced this issue Oct 11, 2021
In the presence of PySocks, httplib2 falls back on it instead of its own bundled `socks.py`. However, exception `ProxyConnectionError` produced by PySocks is a bit different that expected, it lacks `args`. An attempt to extract `errno` from it fails with `IndexError: tuple index out of range` (see httplib2#170). The patch addresses this.
temoto pushed a commit that referenced this issue Oct 11, 2021
Fixes `IndexError: tuple index out of range` trying to extract `errno` from `ProxyConnectionError` from pysocks package, because that exception class lacks `args` attribute.

#170
#202
@temoto
Copy link
Member

temoto commented Oct 11, 2021

@mgorny does it work on new master?

@temoto temoto linked a pull request Oct 11, 2021 that will close this issue
@mgorny
Copy link
Contributor Author

mgorny commented Oct 11, 2021

I've just tried dce3376 and I can still reproduce it.

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

Successfully merging a pull request may close this issue.

3 participants