mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
make sure src exists before creating a symlink
This commit is contained in:
parent
7b0cf76b72
commit
504377d4dd
1 changed files with 2 additions and 0 deletions
|
|
@ -578,6 +578,8 @@ def makedirs(dir):
|
||||||
|
|
||||||
def symlink(src, dst, mkdirs=0):
|
def symlink(src, dst, mkdirs=0):
|
||||||
"""Copy a file or a directory."""
|
"""Copy a file or a directory."""
|
||||||
|
if not os.path.exists(src):
|
||||||
|
raise IOError, "No such file or directory: '%s'" % src
|
||||||
if mkdirs:
|
if mkdirs:
|
||||||
makedirs(os.path.dirname(dst))
|
makedirs(os.path.dirname(dst))
|
||||||
os.symlink(os.path.abspath(src), dst)
|
os.symlink(os.path.abspath(src), dst)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue