diff options
author | Guido van Rossum <guido@python.org> | 2008-10-02 18:55:37 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2008-10-02 18:55:37 (GMT) |
commit | f0af3e30db9475ab68bcb1f1ce0b5581e214df76 (patch) | |
tree | 71efbc67686d96e8c8a81dd97c75c419adf36657 /Lib/genericpath.py | |
parent | fefeca53eebe8665c08ac0c041639ada3c9f9446 (diff) | |
download | cpython-f0af3e30db9475ab68bcb1f1ce0b5581e214df76.zip cpython-f0af3e30db9475ab68bcb1f1ce0b5581e214df76.tar.gz cpython-f0af3e30db9475ab68bcb1f1ce0b5581e214df76.tar.bz2 |
Issue #3187: Better support for "undecodable" filenames. Code by Victor
Stinner, with small tweaks by GvR.
Diffstat (limited to 'Lib/genericpath.py')
-rw-r--r-- | Lib/genericpath.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/genericpath.py b/Lib/genericpath.py index 73d7b26..41ad234 100644 --- a/Lib/genericpath.py +++ b/Lib/genericpath.py @@ -87,6 +87,7 @@ def _splitext(p, sep, altsep, extsep): Extension is everything from the last dot to the end, ignoring leading dots. Returns "(root, ext)"; ext may be empty.""" + # NOTE: This code must work for text and bytes strings. sepIndex = p.rfind(sep) if altsep: @@ -98,8 +99,8 @@ def _splitext(p, sep, altsep, extsep): # skip all leading dots filenameIndex = sepIndex + 1 while filenameIndex < dotIndex: - if p[filenameIndex] != extsep: + if p[filenameIndex:filenameIndex+1] != extsep: return p[:dotIndex], p[dotIndex:] filenameIndex += 1 - return p, '' + return p, p[:0] |