[Python-checkins] python/dist/src/Lib shutil.py,1.28,1.28.10.1
bcannon at users.sourceforge.net
bcannon at users.sourceforge.net
Sat Jun 19 17:39:25 EDT 2004
Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4493/Lib
Modified Files:
Tag: release23-maint
shutil.py
Log Message:
Raise an exception when trying to use shutil.move() to move a directory into
itself.
Closes bug #919012.
Index: shutil.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/shutil.py,v
retrieving revision 1.28
retrieving revision 1.28.10.1
diff -C2 -d -r1.28 -r1.28.10.1
*** shutil.py 23 Feb 2003 21:36:32 -0000 1.28
--- shutil.py 19 Jun 2004 21:39:22 -0000 1.28.10.1
***************
*** 9,12 ****
--- 9,13 ----
import stat
import exceptions
+ from os.path import abspath
__all__ = ["copyfileobj","copyfile","copymode","copystat","copy","copy2",
***************
*** 165,168 ****
--- 166,171 ----
except OSError:
if os.path.isdir(src):
+ if destinsrc(src, dst):
+ raise Error, "Cannot move a directory '%s' into itself '%s'." % (src, dst)
copytree(src, dst, symlinks=True)
rmtree(src)
***************
*** 170,171 ****
--- 173,177 ----
copy2(src,dst)
os.unlink(src)
+
+ def destinsrc(src, dst):
+ return abspath(dst).startswith(abspath(src))
More information about the Python-checkins
mailing list