← Back to team overview

touch-packages team mailing list archive

[Bug 937825] Re: change in urlopen behavior

 

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

-- 
You received this bug notification because you are a member of Ubuntu
Touch seeded packages, which is subscribed to python2.7 in Ubuntu.
https://bugs.launchpad.net/bugs/937825

Title:
  change in urlopen behavior

Status in Python:
  Fix Released
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