[Python-bugs-list] [ python-Bugs-649974 ] urllib.url2pathname('file://host/')...

noreply@sourceforge.net noreply@sourceforge.net
Sat, 07 Dec 2002 01:22:07 -0800


Bugs item #649974, was opened at 2002-12-07 02:22
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=649974&group_id=5470

Category: Python Library
Group: Python 2.2.1
Status: Open
Resolution: None
Priority: 5
Submitted By: Mike Brown (mike_j_brown)
Assigned to: Nobody/Anonymous (nobody)
Summary: urllib.url2pathname('file://host/')...

Initial Comment:
The Unix version of urllib.url2pathname(), when given a 
file URL that contains a host part, returns a path with 
the host embedded in the URL, despite the fact that 
there is no convention for mapping the host into the 
URL. The resulting path is not usable.

For example, on Windows, there is a convention for 
mapping the host part of a URL to and from a NetBIOS 
name. url2pathname('//somehost/path/to/file') returns 
r'\somehost\path\to\file' which is safe to pass into open
() or os.access().

But on Unix, there is no such convention. url2pathname
('//somehost/path/to/file') returns '//somehost/path/to/file', 
which means the same thing as '/somehost/path/to/file' --
 somehost is just another path segment and does not 
actually designate a host.

In my opinion, an exception should be raised in this 
situation; url2pathname() should not try to produce an 
OS path for a remote machine when there is no 
convention for referencing a remote machine in that OS's 
traditional path format. This way, if no exception is 
raised, you know that it's safe to pass the result into 
open() or os.access().

And as noted in other bug reports, 'file://localhost/' is a 
special case that should be treated the same as 'file:///'.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=649974&group_id=5470