win32: path case normalization on case-insensitive filesystems

Alexander Belchenko bialix at ukr.net
Thu Jun 22 13:05:08 BST 2006


Here is code in urlutils.py introduced by John Meinel (annotate show
date 20060610):

def _win32_local_path_to_url(path):
     """Convert a local path like ./foo into a URL like
file:///C:/path/to/foo

...

     return 'file:///' + win32_path[0].lower() + ':' +
escape(win32_path[2:])

This part: 'win32_path[0].lower()' is bad and introduce many errors in
selftest suite and probably cause newest problem with PathNoChild.

Because win32 is case-insensitive filesystem then canonical form for all
path can be created by function of os.path (ntpath) module with name
'normcase'. This function in the end returns strings converted to
lowercase.

So wrong here is that *all* symbols in path should be converted to
lowercase when you convert path to url, not only drive letter. And path
before converting to lowercase should be unicode because otherwise
python unable correct lowercasing non-ascii characters. And this is
means that url and *real* filename (with *real* case of letters) is two
parallel things.

I really don't like filesystems urls because url means that for good
support of case-insensitive filesystems need to save both original
filepath and url.

--
Alexander







More information about the bazaar mailing list