diff options
author | Guido van Rossum <guido@python.org> | 1997-01-22 00:17:26 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1997-01-22 00:17:26 (GMT) |
commit | 73e122f56383e15dc8045caeb5cc853430dd96e9 (patch) | |
tree | 3f23b7d5ed494437402339b3888953c48a7064f1 /Lib/ntpath.py | |
parent | 76f587b7f8d10372f0efc4be94239f3d73c92421 (diff) | |
download | cpython-73e122f56383e15dc8045caeb5cc853430dd96e9.zip cpython-73e122f56383e15dc8045caeb5cc853430dd96e9.tar.gz cpython-73e122f56383e15dc8045caeb5cc853430dd96e9.tar.bz2 |
Fix splitext() to go up to the last dot, not the first.
Diffstat (limited to 'Lib/ntpath.py')
-rw-r--r-- | Lib/ntpath.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Lib/ntpath.py b/Lib/ntpath.py index d67e856..6a77ec8 100644 --- a/Lib/ntpath.py +++ b/Lib/ntpath.py @@ -83,16 +83,21 @@ def split(p): # Split a path in root and extension. -# The extension is everything starting at the first dot in the last +# The extension is everything starting at the last dot in the last # pathname component; the root is everything before that. # It is always true that root + ext == p. def splitext(p): root, ext = '', '' for c in p: - if c in '/\\': + if c in ['/','\\']: root, ext = root + ext + c, '' - elif c == '.' or ext: + elif c == '.': + if ext: + root, ext = root + ext, c + else: + ext = c + elif ext: ext = ext + c else: root = root + c |