GH-127807: pathlib ABCs: remove PurePathBase._raw_paths (#127883)

Remove the `PurePathBase` initializer, and make `with_segments()` and
`__str__()` abstract. This allows us to drop the `_raw_paths` attribute,
and also the `Parser.join()` protocol method.
This commit is contained in:
Barney Gale 2024-12-22 01:17:59 +00:00 committed by GitHub
parent 2a66dd33df
commit a959ea1b0a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 92 additions and 96 deletions

View file

@ -229,6 +229,31 @@ class PurePathTest(test_pathlib_abc.DummyPurePathTest):
self._check_str(p.__fspath__(), ('a/b',))
self._check_str(os.fspath(p), ('a/b',))
def test_bytes(self):
P = self.cls
with self.assertRaises(TypeError):
P(b'a')
with self.assertRaises(TypeError):
P(b'a', 'b')
with self.assertRaises(TypeError):
P('a', b'b')
with self.assertRaises(TypeError):
P('a').joinpath(b'b')
with self.assertRaises(TypeError):
P('a') / b'b'
with self.assertRaises(TypeError):
b'a' / P('b')
with self.assertRaises(TypeError):
P('a').match(b'b')
with self.assertRaises(TypeError):
P('a').relative_to(b'b')
with self.assertRaises(TypeError):
P('a').with_name(b'b')
with self.assertRaises(TypeError):
P('a').with_stem(b'b')
with self.assertRaises(TypeError):
P('a').with_suffix(b'b')
def test_bytes_exc_message(self):
P = self.cls
message = (r"argument should be a str or an os\.PathLike object "