diff options
author | Berker Peksag <berker.peksag@gmail.com> | 2018-08-11 05:45:06 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-11 05:45:06 (GMT) |
commit | 423d05f6f59b24c91b9ef6b2e4ac130316764382 (patch) | |
tree | 74fc09993f9dbbc47425ce60c725e96d98c20290 | |
parent | 077059e0f086cf8c8b7fb9d1f053e38ddc743f59 (diff) | |
download | cpython-423d05f6f59b24c91b9ef6b2e4ac130316764382.zip cpython-423d05f6f59b24c91b9ef6b2e4ac130316764382.tar.gz cpython-423d05f6f59b24c91b9ef6b2e4ac130316764382.tar.bz2 |
bpo-34333: Fix %-formatting in Path.with_suffix() (GH-8663)
-rw-r--r-- | Lib/pathlib.py | 2 | ||||
-rw-r--r-- | Lib/test/test_pathlib.py | 2 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Library/2018-08-04-00-06-28.bpo-34333.5NHG93.rst | 2 |
3 files changed, 5 insertions, 1 deletions
diff --git a/Lib/pathlib.py b/Lib/pathlib.py index 4fe9d4a..6be372e 100644 --- a/Lib/pathlib.py +++ b/Lib/pathlib.py @@ -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 diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py index d95a831..ae7c75d 100644 --- a/Lib/test/test_pathlib.py +++ b/Lib/test/test_pathlib.py @@ -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 diff --git a/Misc/NEWS.d/next/Library/2018-08-04-00-06-28.bpo-34333.5NHG93.rst b/Misc/NEWS.d/next/Library/2018-08-04-00-06-28.bpo-34333.5NHG93.rst new file mode 100644 index 0000000..000f684 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2018-08-04-00-06-28.bpo-34333.5NHG93.rst @@ -0,0 +1,2 @@ +Fix %-formatting in :meth:`pathlib.PurePath.with_suffix` when formatting an +error message. |