Skip to content
Permalink
Browse files

Merge pull request #554 from modcloth/mbh/File.dirname-more-stuff

File.dirname trailing slash (untag specs)
  • Loading branch information
alex committed Mar 26, 2013
2 parents 419ba27 + 8d4a634 commit 1d2d23fac28a085152e1d7ff9a096e98fc98cf57
Showing with 6 additions and 2 deletions.
  1. +0 −2 spec/tags/core/file/dirname_tags.txt
  2. +6 −0 topaz/objects/fileobject.py
@@ -1,4 +1,2 @@
fails:File.dirname
fails:File.dirname ignores a trailing /
fails:File.dirname returns all the components of filename except the last one (edge cases on all platforms)
fails:File.dirname returns all the components of filename except the last one (edge cases on non-windows)
@@ -104,6 +104,12 @@ def method_initialize(self, space, filename, w_mode=None, w_perm_or_opt=None, w_
def method_dirname(self, space, path):
if "/" not in path:
return space.newstr_fromstr(".")
if path == "/":
return space.newstr_fromstr("/")
if path.endswith("/"):
newlen = len(path) - 1
assert newlen >= 0
path = path[:newlen]
idx = path.rfind("/")
while idx > 0 and path[idx - 1] == "/":
idx -= 1

0 comments on commit 1d2d23f

Please sign in to comment.
You can’t perform that action at this time.