mirror of
https://github.com/python/cpython.git
synced 2025-07-16 07:45:20 +00:00
GH-114610: Fix pathlib._abc.PurePathBase.with_suffix('.ext')
handling of stems (#114613)
Raise `ValueError` if `with_suffix('.ext')` is called on a path without a stem. Paths may only have a non-empty suffix if they also have a non-empty stem. ABC-only bugfix; no effect on public classes.
This commit is contained in:
parent
e21754d7f8
commit
809eed4805
3 changed files with 7 additions and 12 deletions
|
@ -327,13 +327,6 @@ class PurePathTest(test_pathlib_abc.DummyPurePathTest):
|
|||
self.assertRaises(ValueError, P('a/b').with_stem, '')
|
||||
self.assertRaises(ValueError, P('a/b').with_stem, '.')
|
||||
|
||||
def test_with_suffix_empty(self):
|
||||
# Path doesn't have a "filename" component.
|
||||
P = self.cls
|
||||
self.assertRaises(ValueError, P('').with_suffix, '.gz')
|
||||
self.assertRaises(ValueError, P('.').with_suffix, '.gz')
|
||||
self.assertRaises(ValueError, P('/').with_suffix, '.gz')
|
||||
|
||||
def test_relative_to_several_args(self):
|
||||
P = self.cls
|
||||
p = P('a/b')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue