pathlib ABCs: defer path joining (#126409)

Defer joining of path segments in the private `PurePathBase` ABC. The new
behaviour matches how the public `PurePath` class handles path segments.

This removes a hard-to-grok difference between the ABCs and the main
classes. It also slightly reduces the size of `PurePath` objects by
eliminating a `_raw_path` slot.
This commit is contained in:
Barney Gale 2024-11-05 21:19:36 +00:00 committed by GitHub
parent f51fd84034
commit 5e9168492f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 43 additions and 46 deletions

View file

@ -86,11 +86,6 @@ class PurePathBaseTest(unittest.TestCase):
p.suffix
with self.assertRaises(e):
p.suffixes
with self.assertRaises(e):
p / 'bar'
with self.assertRaises(e):
'bar' / p
self.assertRaises(e, p.joinpath, 'bar')
self.assertRaises(e, p.with_name, 'bar')
self.assertRaises(e, p.with_stem, 'bar')
self.assertRaises(e, p.with_suffix, '.txt')