fix: python 2 compatibility for symlink creation

This commit is contained in:
Gavin D'souza 2019-12-26 09:36:27 +05:30
parent 658fcac454
commit 04bc216966

View file

@ -47,7 +47,10 @@ def symlink(target, link_name, overwrite=False):
# Pre-empt os.replace on a directory with a nicer message
if os.path.isdir(link_name):
raise IsADirectoryError("Cannot symlink over existing directory: '{}'".format(link_name))
os.replace(temp_link_name, link_name)
try:
os.replace(temp_link_name, link_name)
except AttributeError:
os.renames(temp_link_name, link_name)
except:
if os.path.islink(temp_link_name):
os.remove(temp_link_name)