[Python-bugs-list] [Bug #119485] os.path.basename behaves different from Unix basename

noreply@sourceforge.net noreply@sourceforge.net
Thu, 26 Oct 2000 14:16:53 -0700


Bug #119485, was updated on 2000-Oct-26 14:16
Here is a current snapshot of the bug.

Project: Python
Category: Documentation
Status: Open
Resolution: None
Bug Group: None
Priority: 5
Summary: os.path.basename behaves different from Unix basename

Details: James Troup <troup@debian.org> filed a report about an inconsistency
between os.path.basename() and the Unix basename utility 
(registered in the Debian Bug Tracking System as bug #75605,
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=75605).

os.path.basename('/org/ftp.debian.org/') returns an empty string "", 
while the Unix command "basename /org/ftp.debian.org/" returns 
"ftp.debian.org" (at least that's the case with GNU basename).


os.path.basename() works consistent with its documentation.

I consider this a misbehavior of the basename command, but I guess it's
consistent across all implementations of basename.


I'd suggest that the documentation to os.path.basename mentions that the
result of the function is not necessarily identical to the result of the
basename command. The same applies for os.path.dirname().

    Gregor



02:02:44@auric| ~ $python
Python 1.5.2 (#0, Apr  5 2000, 04:40:10)  [GCC 2.95.2 20000313 (Debian GNU/Linux)] on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import os
>>> print os.path.basename('/org/ftp.debian.org/')

>>> print os.path.basename('/org/ftp.debian.org')
ftp.debian.org
>>>

02:03:24@auric| ~ $basename /org/ftp.debian.org/
ftp.debian.org
02:03:43@auric| ~ $basename /org/ftp.debian.org 
ftp.debian.org
02:03:44@auric| ~ $


For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=119485&group_id=5470