mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
GH-114610: Fix pathlib.PurePath.with_stem('')
handling of file extensions (#114612)
Raise `ValueError` if `with_stem('')` is called on a path with a file extension. Paths may only have an empty stem if they also have an empty suffix.
This commit is contained in:
parent
53c5c17e0a
commit
e3dedeae7a
3 changed files with 15 additions and 1 deletions
|
@ -957,6 +957,8 @@ class DummyPurePathTest(unittest.TestCase):
|
|||
self.assertEqual(P('/').with_stem('d'), P('/d'))
|
||||
self.assertEqual(P('a/b').with_stem(''), P('a/'))
|
||||
self.assertEqual(P('a/b').with_stem('.'), P('a/.'))
|
||||
self.assertRaises(ValueError, P('foo.gz').with_stem, '')
|
||||
self.assertRaises(ValueError, P('/a/b/foo.gz').with_stem, '')
|
||||
|
||||
def test_with_stem_seps(self):
|
||||
P = self.cls
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue