|
14 | 14 | import functools |
15 | 15 | import operator |
16 | 16 | import posixpath |
17 | | -from errno import EINVAL, EXDEV |
| 17 | +from errno import EINVAL |
18 | 18 | from glob import _GlobberBase, _no_recurse_symlinks |
19 | 19 | from stat import S_ISDIR, S_ISLNK, S_ISREG, S_ISSOCK, S_ISBLK, S_ISCHR, S_ISFIFO |
20 | 20 | from pathlib._os import copyfileobj |
@@ -902,45 +902,10 @@ def copy_into(self, target_dir, *, follow_symlinks=True, |
902 | 902 | dirs_exist_ok=dirs_exist_ok, |
903 | 903 | preserve_metadata=preserve_metadata) |
904 | 904 |
|
905 | | - def rename(self, target): |
906 | | - """ |
907 | | - Rename this path to the target path. |
908 | | -
|
909 | | - The target path may be absolute or relative. Relative paths are |
910 | | - interpreted relative to the current working directory, *not* the |
911 | | - directory of the Path object. |
912 | | -
|
913 | | - Returns the new Path instance pointing to the target path. |
914 | | - """ |
915 | | - raise UnsupportedOperation(self._unsupported_msg('rename()')) |
916 | | - |
917 | | - def replace(self, target): |
918 | | - """ |
919 | | - Rename this path to the target path, overwriting if that path exists. |
920 | | -
|
921 | | - The target path may be absolute or relative. Relative paths are |
922 | | - interpreted relative to the current working directory, *not* the |
923 | | - directory of the Path object. |
924 | | -
|
925 | | - Returns the new Path instance pointing to the target path. |
926 | | - """ |
927 | | - raise UnsupportedOperation(self._unsupported_msg('replace()')) |
928 | | - |
929 | 905 | def move(self, target): |
930 | 906 | """ |
931 | 907 | Recursively move this file or directory tree to the given destination. |
932 | 908 | """ |
933 | | - self._ensure_different_file(target) |
934 | | - try: |
935 | | - return self.replace(target) |
936 | | - except UnsupportedOperation: |
937 | | - pass |
938 | | - except TypeError: |
939 | | - if not isinstance(target, PathBase): |
940 | | - raise |
941 | | - except OSError as err: |
942 | | - if err.errno != EXDEV: |
943 | | - raise |
944 | 909 | target = self.copy(target, follow_symlinks=False, preserve_metadata=True) |
945 | 910 | self._delete() |
946 | 911 | return target |
|
0 commit comments