[Twisted-Python] Re: [Twisted-commits] r15209 - basename('/') == '', not IndexError

Jean-Paul Calderone exarkun at divmod.com
Sat Nov 26 12:19:16 EST 2005


On Fri, 25 Nov 2005 20:35:46 -0700, Stephen Thorne <stephen at wolfwood.twistedmatrix.com> wrote:
>Author: stephen
>Date: Fri Nov 25 20:35:45 2005
>New Revision: 15209
>
>Modified:
>   branches/wsanchez/dav/twisted/vfs/pathutils.py
>Log:
>basename('/') == '', not IndexError
>
>Modified: branches/wsanchez/dav/twisted/vfs/pathutils.py
>==============================================================================
>--- branches/wsanchez/dav/twisted/vfs/pathutils.py	(original)
>+++ branches/wsanchez/dav/twisted/vfs/pathutils.py	Fri Nov 25 20:35:45 2005
>@@ -51,7 +51,10 @@
>     return currNode
>
> def basename(path, cwd='/'):
>-    return getAbsoluteSegments(path, cwd)[-1]
>+    s = getAbsoluteSegments(path, cwd)
>+    if s:
>+        return s[-1]
>+    return ''
>
> def dirname(path, cwd='/'):
>     return "/" + "/".join(getAbsoluteSegments(path, cwd)[:-1])

Any plans to revert this?

Jean-Paul




More information about the Twisted-Python mailing list