[Bug 937825] Re: change in urlopen behavior

Bug Watch Updater 937825 at bugs.launchpad.net
Tue Feb 21 15:18:13 UTC 2012


** Changed in: python
       Status: Unknown => Fix Committed

-- 
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 Python:
  Fix Committed
Status in “python2.7” package in Ubuntu:
  Confirmed

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/python/+bug/937825/+subscriptions




More information about the foundations-bugs mailing list