Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os.path.splitext don't handle unix hidden file correctly #41522

Closed
falsetru mannequin opened this issue Feb 4, 2005 · 8 comments
Closed

os.path.splitext don't handle unix hidden file correctly #41522

falsetru mannequin opened this issue Feb 4, 2005 · 8 comments
Labels
stdlib Python modules in the Lib dir

Comments

@falsetru
Copy link
Mannequin

falsetru mannequin commented Feb 4, 2005

BPO 1115886
Nosy @loewis, @birkenfeld, @orsenthil

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2009-09-15.00:01:44.932>
created_at = <Date 2005-02-04.01:27:06.000>
labels = ['library']
title = "os.path.splitext don't handle unix hidden file correctly"
updated_at = <Date 2009-09-15.00:01:44.932>
user = 'https://bugs.python.org/falsetru'

bugs.python.org fields:

activity = <Date 2009-09-15.00:01:44.932>
actor = 'orsenthil'
assignee = 'none'
closed = True
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2005-02-04.01:27:06.000>
creator = 'falsetru'
dependencies = []
files = []
hgrepos = []
issue_num = 1115886
keywords = []
message_count = 8.0
messages = ['24149', '24150', '24151', '24152', '24153', '24154', '92270', '92638']
nosy_count = 8.0
nosy_names = ['loewis', 'georg.brandl', 'jjlee', 'jimjjewett', 'orsenthil', 'grubert', 'falsetru', 'optimix']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue1115886'
versions = ['Python 2.4']

@falsetru
Copy link
Mannequin Author

falsetru mannequin commented Feb 4, 2005

I expected this.
>>> os.path.splitext('/path/to/.Hiddenfile')
('/path/to/.Hiddenfile', '')

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

@falsetru falsetru mannequin closed this as completed Feb 4, 2005
@falsetru falsetru mannequin added the stdlib Python modules in the Lib dir label Feb 4, 2005
@falsetru falsetru mannequin closed this as completed Feb 4, 2005
@falsetru falsetru mannequin added the stdlib Python modules in the Lib dir label Feb 4, 2005
@grubert
Copy link
Mannequin

grubert mannequin commented Jun 13, 2005

Logged In: YES
user_id=147070

from test_posixpath.py ::

self.assertEqual(posixpath.splitext(".ext"), ("", ".ext"))

IMHO should then return (".ext",""). if this is desired ::

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

should do

@birkenfeld
Copy link
Member

Logged In: YES
user_id=1188172

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).

@jjlee
Copy link
Mannequin

jjlee mannequin commented Dec 4, 2005

Logged In: YES
user_id=261020

-1

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/foo.bar')
('a/b/c/foo', '.bar')
>>> os.path.splitext('a/b/c/f.oo.bar')
('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.

@jimjjewett
Copy link
Mannequin

jimjjewett mannequin commented Mar 6, 2007

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.

@loewis
Copy link
Mannequin

loewis mannequin commented Mar 7, 2007

After some discussion on python-dev, I fixed this in r54204.

@optimix
Copy link
Mannequin

optimix mannequin commented Sep 4, 2009

I've read parts of the python-dev discussions, but I don't agree with
this change:
mimetypes.guess_type()
now recognises '.ogg' as None.

@orsenthil
Copy link
Member

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.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir
Projects
None yet
Development

No branches or pull requests

2 participants