mirror of
https://github.com/python/cpython.git
synced 2025-08-22 17:55:18 +00:00
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.
This commit is contained in:
parent
f9b5840fb4
commit
088a09af4b
4 changed files with 30 additions and 11 deletions
|
@ -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):
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue