[Python-Dev] test_urllib2 fails on Win98SE

Paul Prescod paulp@ActiveState.com
Wed, 09 May 2001 13:48:38 -0700


Tim Peters wrote:
> 
>...
> 
> Here's what I know about file URLs on Windows: .

We constantly run into these problems with Komodo. The long and short is
that file URL handling on Windows is totally different than on Unix and
platform-specific code is probably appropriate.

Here's what I know: IE treats the following equivalently:

c:\temp\diff.txt
file:c:\temp\diff.txt
file:/c:\temp\diff.txt
file://c:\temp\diff.txt
file:///c:\temp\diff.txt
file:///////////////////////////////c:\temp\diff.txt

You can also reverse backslashes to slashes and slashes to backslashes
if you like. Interestingly, though, UNC paths seem to work okay (no
matter how you do the slashes and backslashes):

file://americano\home\paulp\foo.html

UNC paths seem to only allow two leading slashes/backslashes.

Truly this is a new level of "be liberal in what you accept". The
algorithm is probably something like:

 1. normalize to forward slashes. 
 2. Remove "file:". 
 3. What you have left should be of the form:

//machine/path

or 

(/*)x:/path

Where x is the drive letter.

-- 
Take a recipe. Leave a recipe.  
Python Cookbook!  http://www.ActiveState.com/pythoncookbook