[Python-bugs-list] normpath error (PR#93)

Guido van Rossum guido@CNRI.Reston.VA.US
Mon, 04 Oct 1999 16:24:16 -0400


> File: posixpath.py and ntpath.py
> Method: normpath
> Problem: initial multiple slashes are not collapsed
> 
> I traced to ntpath.py because I am using WindowsNT 4.0, 
> but I believe that the same error will occur under POSIX.
> 
> Using a path such as:
>     d://data\testdlf/test.dlf
> for a test input I discovered that slashes were converted 
> except for the first 2.
> 
> So I ended up with: 
>     d://data/test/test.dlf
> 
> Making this change to the ntpath.py file fixed this issue.
> os.sep is being added for each iteration of the loop.

This is actually a feature.  When there is no drive letter, Windows
(as well as some Unix versions) has a different interpretation for a
double leading (back)slash.

Some experimentation with NT 4.0 learns that (at least on that system)
if a drive letter is followed by a double backslash, the drive letter
is ignored -- while a double backslash elsewhere in a filename is
treated the same as a single.

I can't say that I understand the wisdom of these rules, but they are
standard NT, and I prefer not to try to "improve" upon it.

--Guido van Rossum (home page: http://www.python.org/~guido/)