os.path.commonprefix seems broken to me. If you ask it to return the common prefix of "/home/swen/spam" and "/home/swan/eggs", it returns "/home/sw". Since we are talking file paths, not strings, I think the common prefix should be "/home". Since my patch changes the semantics of the function, I submitted a patch via SF that implements what I believe to be the correct behavior instead of just checking in the change, so people could comment on it. Also, since the version in ntpath.py was the same as the version in posixpath.py I modified both, replacing "/" with os.sep (is that correct?). Note that I can't check that it returns something useful on NT, though I suspect it will. There is no commonprefix function in macpath.py. Is this a function that would have no meaning on the Mac?
The patch is available for review at
Also, since the version in ntpath.py was the same as the version in posixpath.py I modified both, replacing "/" with os.sep (is that correct?).
see my comment on the site
(in short: you should split on either os.sep or os.altsep, or normalize before splitting. and don't forget UNC names: \machine\directory...).