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

This commit is contained in:
Berker Peksag 2018-08-11 08:45:06 +03:00 committed by GitHub
parent 077059e0f0
commit 423d05f6f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 1 deletions

View File

@ -813,7 +813,7 @@ class PurePath(object):
"""
f = self._flavour
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 == '.':
raise ValueError("Invalid suffix %r" % (suffix))
name = self.name

View File

@ -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, './.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):
P = self.cls

View File

@ -0,0 +1,2 @@
Fix %-formatting in :meth:`pathlib.PurePath.with_suffix` when formatting an
error message.