[issue4265] shutil.copyfile() leaks file descriptors when disk fills
Ammon Riley
report at bugs.python.org
Wed May 5 21:34:50 CEST 2010
Ammon Riley <ammon.riley at gmail.com> added the comment:
You can replace the built-in open(), with one of your own devising:
>>> import shutil
>>> def open(*a, **k):
... raise IOError("faked error.")
...
>>> __builtins__.open = open
>>> shutil.copyfile("snake", "egg")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/shutil.py", line 52 in copyfile
fsrc = open(src, 'rb')
File "<stdin>", line 2, in open
IOError: faked error.
Note that your open() replacement will need a bit of smarts,
since it needs to succeed for some open() calls, and fail for
others, so you'll want to stash the original __builtins__.open()
for future use.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4265>
_______________________________________
More information about the Python-bugs-list
mailing list