[Bug 937825] [NEW] change in urlopen behavior
Jamie Strandboge
jamie at ubuntu.com
Tue Feb 21 14:36:10 UTC 2012
Public bug reported:
The fix for http://bugs.python.org/issue6631 that came in python2.7 2.7.2-13ubuntu5 may cause problems for people. Eg, in 2.7.2-13ubuntu4 this would work:
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/python2.7/urllib.py", line 86, in urlopen
return opener.open(url)
File "/usr/lib/python2.7/urllib.py", line 207, in open
return getattr(self, name)(url)
File "/usr/lib/python2.7/urllib.py", line 462, in open_file
return self.open_local_file(url)
File "/usr/lib/python2.7/urllib.py", line 488, in open_local_file
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)
** Affects: python2.7 (Ubuntu)
Importance: Undecided
Status: New
** Description changed:
The fix for http://bugs.python.org/issue6631 that came in python2.7 2.7.2-13ubuntu5 may cause problems for people. Eg, in 2.7.2-13ubuntu4 this would work:
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/python2.7/urllib.py", line 86, in urlopen
- return opener.open(url)
- File "/usr/lib/python2.7/urllib.py", line 207, in open
- return getattr(self, name)(url)
- File "/usr/lib/python2.7/urllib.py", line 462, in open_file
- return self.open_local_file(url)
- File "/usr/lib/python2.7/urllib.py", line 488, in open_local_file
- raise ValueError("local file url may start with / or file:. Unknown url of type: %s" % url)
+ File "<stdin>", line 1, in <module>
+ File "/usr/lib/python2.7/urllib.py", line 86, in urlopen
+ return opener.open(url)
+ File "/usr/lib/python2.7/urllib.py", line 207, in open
+ return getattr(self, name)(url)
+ File "/usr/lib/python2.7/urllib.py", line 462, in open_file
+ return self.open_local_file(url)
+ File "/usr/lib/python2.7/urllib.py", line 488, in open_local_file
+ 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, but filing this bug as it may cause problems for
+ others.
- While I have worked around it in the Ubuntu CVE tracker and this is not a blocker for my team, but filing this bug as it may cause problems for others.
+ The workaround that 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 changed:
The fix for http://bugs.python.org/issue6631 that came in python2.7 2.7.2-13ubuntu5 may cause problems for people. Eg, in 2.7.2-13ubuntu4 this would work:
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/python2.7/urllib.py", line 86, in urlopen
return opener.open(url)
File "/usr/lib/python2.7/urllib.py", line 207, in open
return getattr(self, name)(url)
File "/usr/lib/python2.7/urllib.py", line 462, in open_file
return self.open_local_file(url)
File "/usr/lib/python2.7/urllib.py", line 488, in open_local_file
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, but filing this bug as it may cause problems for
+ a blocker for my team, filing this bug as it may cause problems for
others.
The workaround that 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:]
+ url = url[2:]
urllib.urlopen(url)
** Description changed:
The fix for http://bugs.python.org/issue6631 that came in python2.7 2.7.2-13ubuntu5 may cause problems for people. Eg, in 2.7.2-13ubuntu4 this would work:
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/python2.7/urllib.py", line 86, in urlopen
return opener.open(url)
File "/usr/lib/python2.7/urllib.py", line 207, in open
return getattr(self, name)(url)
File "/usr/lib/python2.7/urllib.py", line 462, in open_file
return self.open_local_file(url)
File "/usr/lib/python2.7/urllib.py", line 488, in open_local_file
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 that is simply to strip the './' off the front. Eg, a naive fix for the above might be:
+ 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)
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to python2.7 in Ubuntu.
https://bugs.launchpad.net/bugs/937825
Title:
change in urlopen behavior
Status in “python2.7” package in Ubuntu:
New
Bug description:
The fix for http://bugs.python.org/issue6631 that came in python2.7 2.7.2-13ubuntu5 may cause problems for people. Eg, in 2.7.2-13ubuntu4 this would work:
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/python2.7/urllib.py", line 86, in urlopen
return opener.open(url)
File "/usr/lib/python2.7/urllib.py", line 207, in open
return getattr(self, name)(url)
File "/usr/lib/python2.7/urllib.py", line 462, in open_file
return self.open_local_file(url)
File "/usr/lib/python2.7/urllib.py", line 488, in open_local_file
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)
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/python2.7/+bug/937825/+subscriptions
More information about the foundations-bugs
mailing list