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.
This commit is contained in:
Toke Høiland-Jørgensen 2019-11-17 18:06:38 +01:00 committed by Serhiy Storchaka
parent 645005e947
commit 111772fc27
3 changed files with 27 additions and 1 deletions

View file

@ -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: