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

noreply@sourceforge.net noreply@sourceforge.net
Mon, 23 Sep 2002 13:30:51 -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: Closed
>Resolution: Wont Fix
Priority: 5
Submitted By: Ondrej Palkovsky (ondrap)
>Assigned to: Tim Peters (tim_one)
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: Tim Peters (tim_one)
Date: 2002-09-23 16:30

Message:
Logged In: YES 
user_id=31435

Closing as WontFix.  We tried changing this before, and it 
broke working code (luckily, this was discovered before it 
got released).  It works as documented, and code relies on 
it working as documented.

You may with to propose a new function.

Neal, note that almost all the os.path functions just sling 
strings.

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

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