[New-bugs-announce] [issue7751] urllib.urlopen("///C|/foo/bar/spam.foo") IOError: [Errno 22]

Christoph Gohlke report at bugs.python.org
Thu Jan 21 23:55:25 CET 2010


New submission from Christoph Gohlke <cgohlke at uci.edu>:

On Windows 7, Python 2.6 raises an IOError when opening a valid file URL with urllib.urlopen(). A patch to the nturl2path.url2pathname function is attached. It replaces '%7C' by '|' in the url at the top of the url2pathname function.

Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys, urllib
>>> fname = sys.executable
>>> fname
'x:\\python26\\python.exe'
>>> fname = "file:///" + fname.replace('\\', '/').replace(':', '|')
>>> fname
'file:///x|/python26/python.exe'
>>> urllib.urlopen(fname)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "x:\python26\lib\urllib.py", line 87, in urlopen
    return opener.open(url)
  File "x:\python26\lib\urllib.py", line 206, in open
    return getattr(self, name)(url)
  File "x:\python26\lib\urllib.py", line 468, in open_file
    return self.open_local_file(url)
  File "x:\python26\lib\urllib.py", line 482, in open_local_file
    raise IOError(e.errno, e.strerror, e.filename)
IOError: [Errno 22] The filename, directory name, or volume label syntax is incorrect: '\\x|\\python26\\python.exe'

----------
components: Library (Lib), Windows
files: url2pathname.patch
keywords: patch
messages: 98119
nosy: cgohlke
severity: normal
status: open
title: urllib.urlopen("///C|/foo/bar/spam.foo")  IOError: [Errno 22]
type: crash
versions: Python 2.6
Added file: http://bugs.python.org/file15965/url2pathname.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7751>
_______________________________________


More information about the New-bugs-announce mailing list