Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
May 25, 2024

Conversation

barneygale
Copy link
Contributor

@barneygale barneygale commented May 11, 2024

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.


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

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.
@barneygale barneygale merged commit e418fc3 into python:main May 25, 2024
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant