GH-110109: Move pathlib ABCs to new pathlib._abc module. (#112881)

Move `_PurePathBase` and `_PathBase` to a new `pathlib._abc` module, and
drop the underscores from the class names.

Tests are mostly left alone in this commit, but they'll be similarly split
in a subsequent commit.

The `pathlib._abc` module will be published as an independent PyPI package
(similar to how `zipfile._path` is published as `zipp`), to be refined
and stabilised prior to its possible addition to the standard library.
This commit is contained in:
Barney Gale 2023-12-09 15:07:40 +00:00 committed by GitHub
parent c98c40227e
commit a98e7a8112
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 518 additions and 511 deletions

View file

@ -51,7 +51,7 @@ if hasattr(os, 'geteuid'):
class PurePathBaseTest(unittest.TestCase):
cls = pathlib._PurePathBase
cls = pathlib._abc.PurePathBase
def test_magic_methods(self):
P = self.cls
@ -66,7 +66,7 @@ class PurePathBaseTest(unittest.TestCase):
self.assertIs(P.__ge__, object.__ge__)
class DummyPurePath(pathlib._PurePathBase):
class DummyPurePath(pathlib._abc.PurePathBase):
def __eq__(self, other):
if not isinstance(other, DummyPurePath):
return NotImplemented
@ -1586,7 +1586,7 @@ class PurePathSubclassTest(PurePathTest):
#
class PathBaseTest(PurePathBaseTest):
cls = pathlib._PathBase
cls = pathlib._abc.PathBase
def test_unsupported_operation(self):
P = self.cls
@ -1667,7 +1667,7 @@ class DummyPathIO(io.BytesIO):
super().close()
class DummyPath(pathlib._PathBase):
class DummyPath(pathlib._abc.PathBase):
"""
Simple implementation of PathBase that keeps files and directories in
memory.