This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: splitext does not seems to handle filepath ending in .
Type: Stage: resolved
Components: Versions: Python 3.7, Python 3.6, Python 3.4, Python 3.5, Python 2.7
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Devika Sondhi, mrabarnett, serhiy.storchaka, xtreak
Priority: normal Keywords:

Created on 2018-12-19 17:39 by Devika Sondhi, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (5)
msg332157 - (view) Author: Devika Sondhi (Devika Sondhi) Date: 2018-12-19 17:39
posixpath.splitext('.blah.') returns ('.blah', '.') while the expectation was to return an empty extension at the end.
msg332159 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2018-12-19 18:43
Is this similar to previous discussions about leading and trailing dots ?
msg332160 - (view) Author: Matthew Barnett (mrabarnett) * (Python triager) Date: 2018-12-19 18:51
It always returns the dot.

For example:

>>> posixpath.splitext('.blah.txt')
('.blah', '.txt')

If there's no extension (no dot):

>>> posixpath.splitext('blah')
('blah', '')

Not a bug.
msg332189 - (view) Author: Devika Sondhi (Devika Sondhi) Date: 2018-12-20 07:25
Linux (unlike Windows) allows naming a file with a trailing dot. The issue with file name such as '.blah.' is that it does not have an extension and one would expect the base-name without extension to be returned as '.blah.' and not as '.blah'
splitext returns ('.blah','.')
msg332197 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-12-20 08:20
Not a bug. The current behavior is consistent and unsurprising.
Date User Action Args
2022-04-11 14:59:09adminsetgithub: 79719
2018-12-20 08:20:58serhiy.storchakasetstatus: pending -> closed

nosy: + serhiy.storchaka
messages: + msg332197

resolution: not a bug
2018-12-20 07:25:40Devika Sondhisetstatus: closed -> pending
resolution: not a bug -> (no value)
messages: + msg332189
2018-12-19 18:51:39mrabarnettsetstatus: open -> closed

nosy: + mrabarnett
messages: + msg332160

resolution: not a bug
stage: resolved
2018-12-19 18:43:27xtreaksetnosy: + xtreak
messages: + msg332159
2018-12-19 17:39:35Devika Sondhicreate