Issue536120
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.
Created on 2002-03-28 07:28 by s_keim, last changed 2022-04-10 16:05 by admin. This issue is now closed.
Files | ||||
---|---|---|---|---|
File name | Uploaded | Description | Edit | |
posixpath.dif | s_keim, 2002-03-28 07:28 | diff for posixpath.splitext |
Messages (7) | |||
---|---|---|---|
msg39363 - (view) | Author: Sebastien Keim (s_keim) | Date: 2002-03-28 07:28 | |
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. |
|||
msg39364 - (view) | Author: Tim Peters (tim.peters) * | Date: 2002-03-28 08:02 | |
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. |
|||
msg39365 - (view) | Author: Sebastien Keim (s_keim) | Date: 2002-03-28 08:42 | |
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. |
|||
msg39366 - (view) | Author: Sebastien Keim (s_keim) | Date: 2002-03-28 08:55 | |
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. |
|||
msg39367 - (view) | Author: Martin v. Löwis (loewis) * | Date: 2002-03-28 15:51 | |
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. |
|||
msg39368 - (view) | Author: Sebastien Keim (s_keim) | Date: 2002-03-29 08:09 | |
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. |
|||
msg39369 - (view) | Author: Tim Peters (tim.peters) * | Date: 2002-03-29 09:18 | |
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. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-10 16:05:10 | admin | set | github: 36344 |
2002-03-28 07:28:48 | s_keim | create |