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

jmrober1@ingr.com jmrober1@ingr.com
Mon, 4 Oct 1999 16:00:39 -0400 (EDT)


Full_Name: Joe Robertson
Version: 1.5.2
OS: Windows NT
Submission from: ckpnt04.intergraph.com (63.75.137.2)


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.

def normpath(path):
    """Normalize path, eliminating double slashes, etc."""
    path = string.replace(path, "/", "\\")
    prefix, path = splitdrive(path)
    while path[:1] == os.sep:
        #prefix = prefix + os.sep
        path = path[1:]
    ## jmr 10/4/99
    ## add the sep to the prefix only 1 time
    prefix = prefix + os.sep    
    comps = string.splitfields(path, os.sep)
    i = 0


---legal release---
I confirm that, to the best of my knowledge and belief, this
contribution is free of any claims of third parties under
copyright, patent or other rights or interests ("claims").  To
the extent that I have any such claims, I hereby grant to CNRI a
nonexclusive, irrevocable, royalty-free, worldwide license to
reproduce, distribute, perform and/or display publicly, prepare
derivative versions, and otherwise use this contribution as part
of the Python software and its related documentation, or any
derivative versions thereof, at no cost to CNRI or its licensed
users, and to authorize others to do so.

I acknowledge that CNRI may, at its sole discretion, decide
whether or not to incorporate this contribution in the Python
software and its related documentation.  I further grant CNRI
permission to use my name and other identifying information
provided to CNRI by me for use in connection with the Python
software and its related documentation.

Joe Robertson
jmrober1@ingr.com
jmrobert@ro.com