diff options
author | Toke Høiland-Jørgensen <toke@toke.dk> | 2019-11-17 17:06:38 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2019-11-17 17:06:38 (GMT) |
commit | 111772fc27cfe388bc060f019d68a3e33481ec65 (patch) | |
tree | 6cca77de7fdb6a298552815a4a2816f8ceb643dc /Lib/pathlib.py | |
parent | 645005e947c13c4a0706310a2a46112bf63cadc0 (diff) | |
download | cpython-111772fc27cfe388bc060f019d68a3e33481ec65.zip cpython-111772fc27cfe388bc060f019d68a3e33481ec65.tar.gz cpython-111772fc27cfe388bc060f019d68a3e33481ec65.tar.bz2 |
bpo-38811: Check for presence of os.link method in pathlib. (GH-17170)
Fix also the Path.symplink() method implementation for the case when
symlinks are not supported.
Diffstat (limited to 'Lib/pathlib.py')
-rw-r--r-- | Lib/pathlib.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/pathlib.py b/Lib/pathlib.py index d70fde0..5142ff6 100644 --- a/Lib/pathlib.py +++ b/Lib/pathlib.py @@ -418,7 +418,12 @@ class _NormalAccessor(_Accessor): unlink = os.unlink - link_to = os.link + if hasattr(os, "link"): + link_to = os.link + else: + @staticmethod + def link_to(self, target): + raise NotImplementedError("os.link() not available on this system") rmdir = os.rmdir @@ -430,6 +435,7 @@ class _NormalAccessor(_Accessor): if supports_symlinks: symlink = os.symlink else: + @staticmethod def symlink(a, b, target_is_directory): raise NotImplementedError("symlink() not available on this system") else: |