change in urlopen behavior
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Python |
Fix Released
|
Unknown
|
|||
python2.7 (Ubuntu) |
Fix Released
|
Medium
|
Unassigned |
Bug Description
The fix for http://
import urllib
url = "./foo.txt"
urllib.urlopen(url)
In 2.7.2-13ubuntu5 this code causes the following traceback:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/
return opener.open(url)
File "/usr/lib/
return getattr(self, name)(url)
File "/usr/lib/
return self.open_
File "/usr/lib/
raise ValueError("local file url may start with / or file:. Unknown url of type: %s" % url)
ValueError: local file url may start with / or file:. Unknown url of type: ./foo.txt
While I have worked around it in the Ubuntu CVE tracker and this is not a blocker for my team, filing this bug as it may cause problems for others.
The workaround is simply to strip the './' off the front. Eg, a naive fix for the above might be:
import urllib
url = "./foo.txt"
if url.startswith(
url = url[2:]
urllib.urlopen(url)
description: | updated |
description: | updated |
description: | updated |
Changed in python2.7 (Ubuntu): | |
status: | New → Confirmed |
Changed in python: | |
status: | Unknown → Fix Committed |
Changed in python2.7 (Ubuntu): | |
importance: | Undecided → Medium |
Changed in python: | |
status: | Fix Committed → Fix Released |
closing this as fixed upstream for a long time