[Patches] [ python-Patches-536120 ] splitext and leading point of hidden files

noreply@sourceforge.net noreply@sourceforge.net
Thu, 28 Mar 2002 00:42:33 -0800


Patches item #536120, was opened at 2002-03-28 08:28
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=536120&group_id=5470

Category: Library (Lib)
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Sebastien Keim (s_keim)
Assigned to: Nobody/Anonymous (nobody)
Summary: splitext and leading point of hidden files

Initial Comment:
The posixpath.splitext function doesn't do the right thing with leading point of hidden files. For sample: splitext('.emacs')==('','.emacs').
The patch is intended to leave the leading point as part of the name.

Existing code will possibly break, so this patch
is probably quite controversial. If the behaviour change is rejected, the patch could be modified to improve performances without behaviour changes.


----------------------------------------------------------------------

>Comment By: Sebastien Keim (s_keim)
Date: 2002-03-28 09:42

Message:
Logged In: YES 
user_id=498191

oop's your right.

I thought that the for loop was only a reminiscence of the time when the string module was coded in python. In fact it seems that things are a little more complex than I intended :(

But if we replace:
if i<1 or p[i-1]=='/':
by:
if i<0 or i<p.rfind('/'):

We should win in performances without breaking current behavior, or am I missing something else?

About the behavior change proposal:
My opinion is that the 'leading dot means hidden' is a quite strong convention in unixes (and no, not only for the ls utility). 
But this is not true on other os (at least on Mac and Windows). So, if cross platform predictability is important (and I think it is), I agree it is probably better to not try to change this.

----------------------------------------------------------------------

Comment By: Tim Peters (tim_one)
Date: 2002-03-28 09:02

Message:
Logged In: YES 
user_id=31435

I expect this change has scant chance of being accepted.

The idea that leading dot means "hidden" is an arbitrary 
convention of the ls utility, and your desire to call 
a .name file "pure name" instead of "pure extension" seems  
arbitrary too.  The behavior of splitext is perfectly 
predictable as-is across platforms now (note the 
implication:  if you intend to change the semantics for 
posixpath, you'll also have to sell that it should be 
changed for dospath.py, ntpath.py, macpath.py, 
os2emxpath.py, and riscospath.py).

Note that the patched function splits, e.g.,

'/usr/local/tim.one/seven'

into

'/usr/local/tim'

and

'.one/seven'

I assume that's not the result you intended.

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=536120&group_id=5470