[Python-checkins] bpo-34333: Fix %-formatting in Path.with_suffix() (GH-8663)
Berker Peksag
webhook-mailer at python.org
Sat Aug 11 01:45:12 EDT 2018
https://github.com/python/cpython/commit/423d05f6f59b24c91b9ef6b2e4ac130316764382
commit: 423d05f6f59b24c91b9ef6b2e4ac130316764382
branch: master
author: Berker Peksag <berker.peksag at gmail.com>
committer: GitHub <noreply at github.com>
date: 2018-08-11T08:45:06+03:00
summary:
bpo-34333: Fix %-formatting in Path.with_suffix() (GH-8663)
files:
A Misc/NEWS.d/next/Library/2018-08-04-00-06-28.bpo-34333.5NHG93.rst
M Lib/pathlib.py
M Lib/test/test_pathlib.py
diff --git a/Lib/pathlib.py b/Lib/pathlib.py
index 4fe9d4aefc3b..6be372ed320a 100644
--- a/Lib/pathlib.py
+++ b/Lib/pathlib.py
@@ -813,7 +813,7 @@ def with_suffix(self, suffix):
"""
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 d95a831b7b62..ae7c75deb0e6 100644
--- a/Lib/test/test_pathlib.py
+++ b/Lib/test/test_pathlib.py
@@ -577,6 +577,8 @@ def test_with_suffix_common(self):
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 000000000000..000f68422556
--- /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.
More information about the Python-checkins
mailing list