[Python-bugs-list] [ python-Bugs-613169 ] os.path.commonprefix incorrect result

noreply@sourceforge.net noreply@sourceforge.net
Mon, 23 Sep 2002 13:05:07 -0700


Bugs item #613169, was opened at 2002-09-23 07:58
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=613169&group_id=5470

Category: Python Library
Group: Python 2.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Ondrej Palkovsky (ondrap)
Assigned to: Nobody/Anonymous (nobody)
Summary: os.path.commonprefix incorrect result

Initial Comment:
After issuing:
os.path.commonprefix(['/etc','/etcd/hosts'])
The correct result should definitely be '/', but I'm
getting '/etc', which seems to me rather incorrect.
This can be quite nasty as '/usr/binary' and
'/usr/bin2' has a commonprefix of '/usr/bin', while the
correct should be '/usr' etc.

----------------------------------------------------------------------

>Comment By: Neal Norwitz (nnorwitz)
Date: 2002-09-23 16:05

Message:
Logged In: YES 
user_id=33168

The function doesn't work how you expected.  The doc states:
"""
Return the longest path prefix (taken
character-by-character) that is a prefix of all paths in
list. If list is empty, return the empty string (''). Note
that this may return invalid paths because it works a
character at a time.
"""

While, I'm not sure how useful this is (or why it's in
os.path, since it's a general string utility).  I don't
think this can be considered a bug, since the behaviour is
documented.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=613169&group_id=5470