New submission from T L <tapir....@gmail.com>:
Changing the urlopen call to a curl commnand invoke works. $ export http_proxy=socks5://127.0.0.1:8888 https_proxy=socks5://127.0.0.1:8888 # this will raise an exception with string representation is a blank string # at least for url: https://s3.amazonaws.com/mozilla-games/emscripten/packages/llvm/tag/linux_64bit/emscripten-llvm-e1.37.35.tar.gz from urllib2 import urlopen, HTTPError u = urlopen(url) mkdir_p(os.path.dirname(file_name)) with open(file_name, 'wb') as f: file_size = get_content_length(u) if file_size > 0: print("Downloading: %s from %s, %s Bytes" % (file_name, url, file_size)) else: print("Downloading: %s from %s" % (file_name, url)) file_size_dl = 0 block_sz = 8192 while True: buffer = u.read(block_sz) if not buffer: break file_size_dl += len(buffer) f.write(buffer) # this alternative way works import commands status, output = commands.getstatusoutput("curl -L --output " + file_name + " " + url) ---------- components: Library (Lib) messages: 321010 nosy: T L2 priority: normal severity: normal status: open title: urllib2.urlopen fails if http_proxy(s) is set to a sock5 proxy type: behavior versions: Python 2.7 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue34038> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com