Summary: | sys-apps/portage-2.1.10.49 - PORTAGE_BINHOST="http(s)://user:password@domain/path/to/packages" produces traceback with python-3.2 | ||
---|---|---|---|
Product: | Portage Development | Reporter: | Lars Wendler (Polynomial-C) (RETIRED) <polynomial-c> |
Component: | Core - Configuration | Assignee: | Portage team <dev-portage> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | Normal | ||
Version: | unspecified | ||
Hardware: | All | ||
OS: | Linux | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- | |
Bug Depends on: | 415579 | ||
Bug Blocks: | 409383 | ||
Attachments: | portage-urlopen.patch |
Description
Lars Wendler (Polynomial-C) (RETIRED)
2012-04-29 12:53:04 UTC
I forgot to mention, this only happens when python-3.2 is set via "eselect python". The problem is gone once python-2.7 is set via eselect. Currently Portage uses urllib.urlopen() with Python 2 and urllib.request.urlopen() with Python 3. urllib.request module of Python 3 corresponds to urllib2 module of Python 2. urllib2.urlopen() has the same problem: $ python2.7 -c 'import urllib2; urllib2.urlopen("http://user:password@gentoo.org")' Traceback (most recent call last): File "<string>", line 1, in <module> File "/usr/lib64/python2.7/urllib2.py", line 126, in urlopen return _opener.open(url, data, timeout) File "/usr/lib64/python2.7/urllib2.py", line 400, in open response = self._open(req, data) File "/usr/lib64/python2.7/urllib2.py", line 418, in _open '_open', req) File "/usr/lib64/python2.7/urllib2.py", line 378, in _call_chain result = func(*args) File "/usr/lib64/python2.7/urllib2.py", line 1207, in http_open return self.do_open(httplib.HTTPConnection, req) File "/usr/lib64/python2.7/urllib2.py", line 1146, in do_open h = http_class(host, timeout=req.timeout) # will parse host:port File "/usr/lib64/python2.7/httplib.py", line 693, in __init__ self._set_hostport(host, port) File "/usr/lib64/python2.7/httplib.py", line 721, in _set_hostport raise InvalidURL("nonnumeric port: '%s'" % host[i+1:]) httplib.InvalidURL: nonnumeric port: 'password@gentoo.org' Created attachment 310549 [details, diff]
portage-urlopen.patch
This patch removes usage of deprecated urllib.urlopen() and probably fixes usage of urlopen() from new modules. Please test this patch with Python 2 and 3. I can commit it if it works.
The previous patch wasn't working with URLs, which require authentication, probably due to realm=None. The new patch explicitly uses HTTPPasswordMgrWithDefaultRealm instead of HTTPPasswordMgr. I have successfully tested portage.util.urlopen() on localhost:8080/manage (from Zope), which requires authentication. Commit: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commitdiff;h=0a9cc38a66ded0cf0e5b534cb24b970fc9c21920 You might test sys-apps/portage-9999. This is released for testing in 2.2.0_alpha102. This is fixed in 2.1.10.58. Since the code for this bug doesn't work with all protocols, I've made it so that it's only used as a fallback: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=2c191d17c5c879c51aeb1c6043d9185b9a5887c0 |