]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
GH-127456: pathlib ABCs: add protocol for path parser (#127494)
authorBarney Gale <barney.gale@gmail.com>
Mon, 9 Dec 2024 18:31:22 +0000 (18:31 +0000)
committerGitHub <noreply@github.com>
Mon, 9 Dec 2024 18:31:22 +0000 (18:31 +0000)
commit5c89adf385aaaca97c2ee9074f8b1fda0f57ad26
tree21fac62c4e6ca6f0e2e4223ca16b680921261760
parente85f2f1703e0f79cfd0d0e3010190b71c0eb18da
GH-127456: pathlib ABCs: add protocol for path parser (#127494)

Change the default value of `PurePathBase.parser` from `ParserBase()` to
`posixpath`. As a result, user subclasses of `PurePathBase` and `PathBase`
use POSIX path syntax by default, which is very often desirable.

Move `pathlib._abc.ParserBase` to `pathlib._types.Parser`, and convert it
to a runtime-checkable protocol.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Lib/pathlib/_abc.py
Lib/pathlib/_types.py [new file with mode: 0644]
Lib/test/test_pathlib/test_pathlib_abc.py