summaryrefslogtreecommitdiff
path: root/Lib
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2018-08-03 14:45:20 -0700
committerBerker Peksag <berker.peksag@gmail.com>2018-08-04 00:45:20 +0300
commit764f9d09b03654d7cd70d59afafafd51d24f2750 (patch)
tree639afae69062eaedb86d39cc4ff2b3fc6db36426 /Lib
parentbpo-30317: Fix multiprocessing test_timeout() (GH-8621) (diff)
downloadcpython-764f9d09b03654d7cd70d59afafafd51d24f2750.tar.gz
cpython-764f9d09b03654d7cd70d59afafafd51d24f2750.tar.bz2
cpython-764f9d09b03654d7cd70d59afafafd51d24f2750.zip
bpo-34329: Doc'd how to remove suffix of pathlib.Path() (GH-8655)
(cherry picked from commit 46dc4e34ed8005a688d7f3512844ef227a3465f4) Co-authored-by: Stefan Otte <stefan.otte@gmail.com>
Diffstat (limited to 'Lib')
-rw-r--r--Lib/pathlib.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/pathlib.py b/Lib/pathlib.py
index 44788c02c2f..5e130110f2e 100644
--- a/Lib/pathlib.py
+++ b/Lib/pathlib.py
@@ -823,8 +823,10 @@ class PurePath(object):
self._parts[:-1] + [name])
def with_suffix(self, suffix):
- """Return a new path with the file suffix changed (or added, if none)."""
- # XXX if suffix is None, should the current suffix be removed?
+ """Return a new path with the file suffix changed. If the path
+ has no suffix, add given suffix. If the given suffix is an empty
+ string, remove the suffix from the path.
+ """
f = self._flavour
if f.sep in suffix or f.altsep and f.altsep in suffix:
raise ValueError("Invalid suffix %r" % (suffix))