patch for os.path.commonprefix (changes semantics - pls review)
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 http://sourceforge.net/patch/?func=detailpatch&patch_id=100788&group_id=5470 Skip
skip wrote:
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...). </F>
participants (2)
-
Fredrik Lundh
-
Skip Montanaro