summaryrefslogtreecommitdiffstats
path: root/Lib/pathlib.py
diff options
context:
space:
mode:
authorhui shang <shangdahao@gmail.com>2019-09-11 13:26:49 (GMT)
committerJason R. Coombs <jaraco@jaraco.com>2019-09-11 13:26:49 (GMT)
commit088a09af4bdeff52b9dedeb7acd1e82069f37d98 (patch)
tree26aaebe83ddd99faa504ca67e8a97c1b8e4d5263 /Lib/pathlib.py
parentf9b5840fb4497a9e2ba2c1f01ad0dafba04c8496 (diff)
downloadcpython-088a09af4bdeff52b9dedeb7acd1e82069f37d98.zip
cpython-088a09af4bdeff52b9dedeb7acd1e82069f37d98.tar.gz
cpython-088a09af4bdeff52b9dedeb7acd1e82069f37d98.tar.bz2
bpo-31163: Added return values to pathlib.Path instance's rename and replace methods. (GH-13582)
* bpo-31163: Added return values to pathlib.Path instance's rename and replace methods.
Diffstat (limited to 'Lib/pathlib.py')
-rw-r--r--Lib/pathlib.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/pathlib.py b/Lib/pathlib.py
index 80923c7..7bd66c1 100644
--- a/Lib/pathlib.py
+++ b/Lib/pathlib.py
@@ -1341,20 +1341,24 @@ class Path(PurePath):
def rename(self, target):
"""
- Rename this path to the given path.
+ Rename this path to the given path,
+ and return a new Path instance pointing to the given path.
"""
if self._closed:
self._raise_closed()
self._accessor.rename(self, target)
+ return self.__class__(target)
def replace(self, target):
"""
Rename this path to the given path, clobbering the existing
- destination if it exists.
+ destination if it exists, and return a new Path instance
+ pointing to the given path.
"""
if self._closed:
self._raise_closed()
self._accessor.replace(self, target)
+ return self.__class__(target)
def symlink_to(self, target, target_is_directory=False):
"""