Skip to content

GH-110109: pathlib ABCs: do not vary path syntax by host OS.#113219

Merged
barneygale merged 7 commits intopython:mainfrom
barneygale:gh-110109-purepathbase-posixpath
Dec 22, 2023
Merged

GH-110109: pathlib ABCs: do not vary path syntax by host OS.#113219
barneygale merged 7 commits intopython:mainfrom
barneygale:gh-110109-purepathbase-posixpath

Conversation

@barneygale
Copy link
Contributor

@barneygale barneygale commented Dec 16, 2023

Change the value of pathlib._abc.PurePathBase.pathmod from os.path to posixpath.

User subclasses of PurePathBase and PathBase previously used the host OS's path syntax, e.g. backslashes as separators on Windows. This is wrong in most use cases, and likely to catch developers out unless they test on both Windows and non-Windows machines.

In this patch we change the default to POSIX syntax, regardless of OS. This is somewhat arguable (why not make all aspects of syntax abstract and individually configurable?) but an improvement all the same.

This change has no effect on PurePath, Path, nor their subclasses. Only private APIs are affected.

Loading
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.

1 participant