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

noreply@sourceforge.net noreply@sourceforge.net
Fri, 29 Mar 2002 01:18:28 -0800


Patches item #536120, was opened at 2002-03-28 02: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: Closed
Resolution: Rejected
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: Tim Peters (tim_one)
Date: 2002-03-29 04:18

Message:
Logged In: YES 
user_id=31435

BTW, if it *weren't* for the code breakage, I'd be in favor 
of doing this.  A quick survey at work yesterday showed 
that most of those who expressed a preference were at least 
mildly in favor of calling .emacs "pure name, no 
extension".  While the docstring is clear that it's treated 
as "pure extension", and that's what the code does too, the 
Library Manual docs are consistent with either notion.

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

Comment By: Sebastien Keim (s_keim)
Date: 2002-03-29 03:09

Message:
Logged In: YES 
user_id=498191

After a good night, I understand that this patch would break too much code and be very confusing. So I suggest to close it as rejected.

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

Comment By: Martin v. Löwis (loewis)
Date: 2002-03-28 10:51

Message:
Logged In: YES 
user_id=21627

I also dislike this patch. The current behaviour completely
matches the documented behaviour; changing it might break
existing applications. If you need a different behaviour,
write a different function.

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

Comment By: Sebastien Keim (s_keim)
Date: 2002-03-28 03:55

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: Sebastien Keim (s_keim)
Date: 2002-03-28 03: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 03: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