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: os.path.splitext don't handle unix hidden file correctly
Type: Stage:
Components: Library (Lib) Versions: Python 2.4
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: falsetru, georg.brandl, grubert, jimjjewett, jjlee, loewis, optimix, orsenthil
Priority: normal Keywords:

Created on 2005-02-04 01:27 by falsetru, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (8)
msg24149 - (view) Author: Jeong-Min Lee (falsetru) Date: 2005-02-04 01:27
I expected this.
>>> os.path.splitext('/path/to/.Hiddenfile')
('/path/to/.Hiddenfile', '')

but got this.
>>> os.path.splitext('/path/to/.Hiddenfile')
('/path/to/', '.Hiddenfile')

msg24150 - (view) Author: engelbert gruber (grubert) * Date: 2005-06-13 14:12
Logged In: YES 

from ::

  self.assertEqual(posixpath.splitext(".ext"), ("", ".ext"))
IMHO should then return (".ext",""). if this is desired ::

  if i<=p.rfind('/'):                                                                                   
          return p, ''                                                                                  
          return p[:i], p[i:]                                                                          

should do
msg24151 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2005-06-18 21:05
Logged In: YES 

Interestingly, altering the behaviour of splitext in such a
way does not contradict the documentation, which is:

Split the pathname path into a pair (root, ext) such that
root + ext == path, and ext is empty or begins with a period
and contains at most one period.

Personally I'm in favour of this change (on Unix it makes
sense, while on Windows you can hardly find an
"extension-only" file).
msg24152 - (view) Author: John J Lee (jjlee) Date: 2005-12-04 14:44
Logged In: YES 


I hate to be a stick-in-the-mud, but the existing behaviour
is what I would expect, and seems to be regular -- always
picks the last dot:

>>> os.path.splitext('a/b/c/')
('a/b/c/foo', '.bar')
>>> os.path.splitext('a/b/c/')
('a/b/c/f.oo', '.bar')
>>> os.path.splitext('a/b/c/.foo')
('a/b/c/', '.foo')
>>> os.path.splitext('a/b/c/.foo.txt')
('a/b/c/.foo', '.txt')

Changing it would surely break somebody's code too, of course.
msg24153 - (view) Author: Jim Jewett (jimjjewett) Date: 2007-03-06 23:20
1462106 is a patch, though perhaps not the latest.

python-dev is currently debating whether to fix this behavior or maintain backwards-compatibility.

That suggests that it at least won't be changed in a bugfix version (like 2.4.x), and the group should be changed to 2.6.
msg24154 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2007-03-07 11:05
After some discussion on python-dev, I fixed this in r54204.
msg92270 - (view) Author: Alexandru Munteanu (optimix) Date: 2009-09-04 22:16
I've read parts of the python-dev discussions, but I don't agree with
this change:
now recognises '.ogg' as None.
msg92638 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2009-09-15 00:01
Alexandru: You commented on a closed issue. If you see any problem
with mimetypes.guess_type() w.r.t to .ogg files, please open a new
open stating your problem.
Date User Action Args
2022-04-11 14:56:09adminsetgithub: 41522
2009-09-15 00:01:44orsenthilsetnosy: + orsenthil
messages: + msg92638
2009-09-04 22:16:05optimixsetnosy: + optimix
messages: + msg92270
2005-02-04 01:27:06falsetrucreate