Commit 423d05f6 authored by Berker Peksag's avatar Berker Peksag Committed by GitHub

bpo-34333: Fix %-formatting in Path.with_suffix() (GH-8663)

parent 077059e0
...@@ -813,7 +813,7 @@ class PurePath(object): ...@@ -813,7 +813,7 @@ class PurePath(object):
""" """
f = self._flavour f = self._flavour
if f.sep in suffix or f.altsep and f.altsep in suffix: if f.sep in suffix or f.altsep and f.altsep in suffix:
raise ValueError("Invalid suffix %r" % (suffix)) raise ValueError("Invalid suffix %r" % (suffix,))
if suffix and not suffix.startswith('.') or suffix == '.': if suffix and not suffix.startswith('.') or suffix == '.':
raise ValueError("Invalid suffix %r" % (suffix)) raise ValueError("Invalid suffix %r" % (suffix))
name = self.name name = self.name
......
...@@ -577,6 +577,8 @@ class _BasePurePathTest(object): ...@@ -577,6 +577,8 @@ class _BasePurePathTest(object):
self.assertRaises(ValueError, P('a/b').with_suffix, '.c/.d') self.assertRaises(ValueError, P('a/b').with_suffix, '.c/.d')
self.assertRaises(ValueError, P('a/b').with_suffix, './.d') self.assertRaises(ValueError, P('a/b').with_suffix, './.d')
self.assertRaises(ValueError, P('a/b').with_suffix, '.d/.') self.assertRaises(ValueError, P('a/b').with_suffix, '.d/.')
self.assertRaises(ValueError, P('a/b').with_suffix,
(self.flavour.sep, 'd'))
def test_relative_to_common(self): def test_relative_to_common(self):
P = self.cls P = self.cls
......
Fix %-formatting in :meth:`pathlib.PurePath.with_suffix` when formatting an
error message.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment