cpython icon indicating copy to clipboard operation
cpython copied to clipboard

GH-82805: Fix handling of single-dot file extensions in pathlib

Open barneygale opened this issue 1 year ago • 0 comments

pathlib now treats "." as a valid file extension (suffix). This brings it in line with os.path.splitext().

In the (private) pathlib ABCs, we add a new ParserBase.splitext() method that splits a path into a (root, ext) pair, like os.path.splitext(). This method is called by PurePathBase.stem, suffix, etc. In a future version of pathlib, we might make these base classes public, and so users will be able to define their own splitext() method to control file extension splitting.

In pathlib.PurePath we add optimised stem, suffix and suffixes properties that don't use splitext(), which avoids computing the path base name twice.

  • Issue: gh-82805

📚 Documentation preview 📚: https://cpython-previews--118952.org.readthedocs.build/

barneygale avatar May 11 '24 19:05 barneygale