Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Fix atrocious logic in symlink()
Browse files Browse the repository at this point in the history
If the desired result is already in effect, do nothing. Otherwise, proceed
with the previous behaviour, but handle permissions errors correctly.
  • Loading branch information
infinity0 committed Feb 22, 2017
1 parent 27d41fa commit 316c6c3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/sage/repl/ipython_kernel/install.py
Expand Up @@ -89,11 +89,19 @@ def symlink(self, src, dst):
sage: os.listdir(path)
['b']
"""
if os.path.islink(dst):
origsrc = os.path.join(os.path.dirname(dst), os.readlink(dst))
if os.path.abspath(origsrc) == os.path.abspath(src):
return
try:
os.remove(dst)
except OSError as err:
if err.errno == errno.EEXIST:
return
elif err.errno == errno.ENOENT:
pass
else:
raise
os.symlink(src, dst)

def use_local_mathjax(self):
Expand Down

0 comments on commit 316c6c3

Please sign in to comment.