classification
Title: Fix os.path.commonprefix to work by directory components
Type: Stage:
Components: None Versions:
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: skip.montanaro Nosy List: effbot, gvanrossum, skip.montanaro
Priority: normal Keywords: patch

Created on 2000-07-09 15:32 by skip.montanaro, last changed 2000-07-12 16:58 by skip.montanaro. This issue is now closed.

Files
File name Uploaded Description Edit
None skip.montanaro, 2000-07-09 15:32 None
Messages (7)
msg33137 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2000-07-09 15:32
 
msg33138 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2000-07-09 21:25
Why use n - copy.copy(m)?  It's much simpler to use n = m[:].

Note that dospath probably also has this.  And macpath should have one.

I'm +1 on fixing the functionality if it's indeed broken as Skip reports; haven't looked at the code in detail (except I noted the import copy).
msg33139 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2000-07-12 15:18
Check it in -- you already checked in the changes to the test!

I propose to use m[:] instead of copy.copy(m), and not import the copy module.
msg33140 - (view) Author: Fredrik Lundh (effbot) * (Python committer) Date: 2000-07-09 15:37
splitting on os.sep isn't good enough for Windows (it supports both "/" and "\").  the correct way would be to split on either os.sep or os.altsep (if not None), or to normalize the path's before comparing them.

except for this, I'm +0 on this one.
msg33141 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2000-07-11 16:45
Guido asked:

   > Why use n - copy.copy(m)? It's much simpler to use n = m[:].

Just a brain fart.  I will upload a revised patch.

I will also try splitting on both os.sep and os.altsep as Fredrik indicated.
msg33142 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2000-07-12 00:22
This version of the patch tries splitting with os.sep then
if that doesn't create a length > 1 list tries os.altsep.
It also adds the same code to ntpath.py, dospath.py and macpath.py.  Someone needs to test them!
msg33143 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2000-07-12 16:58
checked in
History
Date User Action Args
2000-07-09 15:32:38skip.montanarocreate