[Python-Dev] Proposal to revert r54204 (splitext change)

Michael Foord fuzzyman at voidspace.org.uk
Wed Mar 14 22:41:36 CET 2007

Delaney, Timothy (Tim) wrote:
> Phillip J. Eby wrote:
>> In addition to being made in the face of controversy and opposition,
>> this 
>> change is an alteration to *documented and tested* behavior and thus
>> cannot reasonably be considered a mere bug fix.
> FWIW, I support Phillip on this. There can be no question that the old behaviour was expected.
Expected ? It's perverse. :-)

> IMO this is just gratuitous breakage. The only fix that shold be made is to the splitext documentation to match the docstring.

> A change to the documented behaviour should require a __future__ import for at least one version. That's even assuming that the change is desireable (I don't believe so). We have multiple anecdotes of actual, existing code that *will* break with this change. So far I haven't seen any actual code posted that is currently broken by the existing behaviour.
There was code posted that used the (almost entirely sane) pattern :

new_filename  = os.path.splitext(old_filename)[1] + '.bak'

That was broken but is now fixed. It follows the entirely natural 
assumption that filename without an extension would not have the 
filename put in the extension half of the tuple.

The documentation (not the docstring) actually says :

splitext( path)

    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.

Even the docstring only states that either part may be empty, hardly 
documenting what is clearly a misfeature.

Michael Foord

> Tim Delaney
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: http://mail.python.org/mailman/options/python-dev/fuzzyman%40voidspace.org.uk

More information about the Python-Dev mailing list