diff -r 1dd7dbac95da Lib/shutil.py --- a/Lib/shutil.py Sun May 02 11:55:57 2010 +0200 +++ b/Lib/shutil.py Sun May 02 15:47:44 2010 -0400 @@ -79,15 +79,9 @@ # XXX What about other special files? (sockets, devices...) if stat.S_ISFIFO(st.st_mode): raise SpecialFileError("`%s` is a named pipe" % fn) - try: - fsrc = open(src, 'rb') - fdst = open(dst, 'wb') - copyfileobj(fsrc, fdst) - finally: - if fdst: - fdst.close() - if fsrc: - fsrc.close() + with open(src, 'rb') as fsrc: + with open(dst, 'wb') as fdst: + copyfileobj(fsrc, fdst) def copymode(src, dst): """Copy mode bits from src to dst"""