This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Daniel Wallace
Recipients Daniel Wallace, T L2
Date 2019-05-04.15:34:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1556984093.16.0.127094086649.issue34038@roundup.psfhosted.org>
In-reply-to
Content
I think this is caused by the fact that socks5 proxies are not supported?

$ cat ~/issue34038.py
from urllib.request import urlopen, HTTPError

url = 'http://icanhazip.com'
u = urlopen(url)

$./python.exe ~/issue34038.py
Traceback (most recent call last):
  File "/Users/dwallace/issue34038.py", line 4, in <module>
    u = urlopen(url)
  File "/Users/dwallace/workspace/cpython/Lib/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/Users/dwallace/workspace/cpython/Lib/urllib/request.py", line 524, in open
    response = self._open(req, data)
  File "/Users/dwallace/workspace/cpython/Lib/urllib/request.py", line 541, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
  File "/Users/dwallace/workspace/cpython/Lib/urllib/request.py", line 502, in _call_chain
    result = func(*args)
  File "/Users/dwallace/workspace/cpython/Lib/urllib/request.py", line 804, in <lambda>
    meth(r, proxy, type))
  File "/Users/dwallace/workspace/cpython/Lib/urllib/request.py", line 832, in proxy_open
    return self.parent.open(req, timeout=req.timeout)
  File "/Users/dwallace/workspace/cpython/Lib/urllib/request.py", line 524, in open
    response = self._open(req, data)
  File "/Users/dwallace/workspace/cpython/Lib/urllib/request.py", line 546, in _open
    return self._call_chain(self.handle_open, 'unknown',
  File "/Users/dwallace/workspace/cpython/Lib/urllib/request.py", line 502, in _call_chain
    result = func(*args)
  File "/Users/dwallace/workspace/cpython/Lib/urllib/request.py", line 1386, in unknown_open
    raise URLError('unknown url type: %s' % type)
urllib.error.URLError: <urlopen error unknown url type: socks5>

Though the error message could be better.

You can work around this by setting the default socket.

import urllib.request
import socket
import socks

url = 'http://icanhazip.com'
socks.set_default_proxy(socks.SOCKS5, "localhost",port=8888)
socket.socket = socks.socksocket
print(urllib.request.urlopen(url).read())
History
Date User Action Args
2019-05-04 15:34:53Daniel Wallacesetrecipients: + Daniel Wallace, T L2
2019-05-04 15:34:53Daniel Wallacesetmessageid: <1556984093.16.0.127094086649.issue34038@roundup.psfhosted.org>
2019-05-04 15:34:53Daniel Wallacelinkissue34038 messages
2019-05-04 15:34:52Daniel Wallacecreate