make sure src exists before creating a symlink

This commit is contained in:
Just van Rossum 2003-01-17 20:02:06 +00:00
parent 7b0cf76b72
commit 504377d4dd
1 changed files with 2 additions and 0 deletions

View File

@ -578,6 +578,8 @@ def makedirs(dir):
def symlink(src, dst, mkdirs=0):
"""Copy a file or a directory."""
if not os.path.exists(src):
raise IOError, "No such file or directory: '%s'" % src
if mkdirs:
makedirs(os.path.dirname(dst))
os.symlink(os.path.abspath(src), dst)