urllib2.urlopen fails to parse the URI when user:password is specified but no port - update-manager fails to download changelog
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
python2.6 (Ubuntu) |
Won't Fix
|
Undecided
|
Unassigned | ||
update-manager (Ubuntu) |
Invalid
|
Low
|
Unassigned |
Bug Description
Binary package hint: update-manager
update-manager encountered unhandled exception when attempting to download changelog for the ubuntu-
Unhandled exception in thread started by <bound method MyCache.
Traceback (most recent call last):
File "/usr/lib/
self.
File "/usr/lib/
changelog = self._get_
File "/usr/lib/
changelog = urllib2.
File "/usr/lib/
return _opener.open(url, data, timeout)
File "/usr/lib/
response = self._open(req, data)
File "/usr/lib/
'_open', req)
File "/usr/lib/
result = func(*args)
File "/usr/lib/
return self.do_
File "/usr/lib/
h = http_class(host, timeout=
File "/usr/lib/
HTTPConnect
File "/usr/lib/
self.
File "/usr/lib/
raise InvalidURL(
httplib.InvalidURL: nonnumeric port: '<email address hidden>'
Note, above I replaced the actual password with 'XXX' sequence
ProblemType: Bug
DistroRelease: Ubuntu 10.04
Package: update-manager 1:0.134.10
ProcVersionSign
Uname: Linux 2.6.32-24-generic x86_64
NonfreeKernelMo
Architecture: amd64
Date: Thu Aug 26 17:53:24 2010
InstallationMedia: Ubuntu 10.04 LTS "Lucid Lynx" - Release amd64 (20100429)
PackageArchitec
ProcEnviron:
PATH=(custom, user)
LANG=pl_PL.utf8
SHELL=/bin/bash
SourcePackage: update-manager
Changed in python2.6 (Ubuntu): | |
status: | New → Won't Fix |
Thanks for your report.
This is a problem with python failing to parse a valid scheme according to RFC 3986 (http:// tools.ietf. org/html/ rfc3986) username: password@ domain/ path?query_ string# anchor') python2. 6/urllib2. py", line 126, in urlopen python2. 6/urllib2. py", line 391, in open python2. 6/urllib2. py", line 409, in _open python2. 6/urllib2. py", line 369, in _call_chain python2. 6/urllib2. py", line 1170, in http_open open(httplib. HTTPConnection, req) python2. 6/urllib2. py", line 1116, in do_open req.timeout) # will parse host:port python2. 6/httplib. py", line 661, in __init__ _set_hostport( host, port) python2. 6/httplib. py", line 686, in _set_hostport "nonnumeric port: '%s'" % host[i+1:])
To reproduce:
$ python
Python 2.6.6 (r266:84292, Aug 24 2010, 21:47:18)
[GCC 4.4.5 20100816 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib2
>>> urllib2.urlopen('http://
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/
return _opener.open(url, data, timeout)
File "/usr/lib/
response = self._open(req, data)
File "/usr/lib/
'_open', req)
File "/usr/lib/
result = func(*args)
File "/usr/lib/
return self.do_
File "/usr/lib/
h = http_class(host, timeout=
File "/usr/lib/
self.
File "/usr/lib/
raise InvalidURL(
httplib.InvalidURL: nonnumeric port: 'password@domain'
I guess that the parser cuts the scheme at the first ':' to find the port but it's the authority part. username: password@ domain: 80/path? query_string# anchor')
Interestingly it doesn't fail if you provide the port:
>>> urllib2.urlopen('http://
[...]
urllib2.URLError: <urlopen error [Errno -2] Name or service not known>
I'm adding a python task and confirming the update-manager task because it should correctly handle the exception.