mirror of
https://github.com/python/cpython.git
synced 2025-07-12 13:55:34 +00:00
Merged revisions 80830 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r80830 | tarek.ziade | 2010-05-06 00:15:31 +0200 (Thu, 06 May 2010) | 1 line Fixed #4265: shutil.copyfile() was leaking file descriptors when disk fills ........
This commit is contained in:
parent
55f8ae28a1
commit
ae4d5c6b64
3 changed files with 111 additions and 10 deletions
|
@ -96,15 +96,9 @@ def copyfile(src, dst):
|
|||
# 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"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue