[Python-Dev] commonprefix - the beast just won't die...
Skip Montanaro
skip@mojam.com (Skip Montanaro)
Tue, 22 Aug 2000 09:45:27 -0500 (CDT)
I reverted the changes to {posix,nt,dos}path.commonprefix this morning,
updated the tests (still to be checked in) and was starting to work on
documentation changes, when I realized that something Guido said about using
dirname to trim to the common directory prefix is probably not correct.
Here's an example. The common prefix of ["/usr/local", "/usr/local/bin"] is
"/usr/local". If you blindly apply dirname to that (which is what I think
Guido suggested as the way to make commonprefix do what I wanted, you wind
up with "/usr", which isn't going to be correct on most Unix flavors.
Instead, you need to check that the prefix doesn't exist or isn't a
directory before applying dirname. (And of course, that only works on the
machine containing the paths in question. You should be able to import
posixpath on a Mac and feed it Unix-style paths, which you won't be able to
check for existence.)
Based on this problem, I'm against documenting using dirname to trim the
commonprefix output to a directory prefix. I'm going to submit a patch with
the test case and minimal documentation changes and leave it at that for
now.
Skip