Ammon Riley <ammon.ri...@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 <rep...@bugs.python.org> <http://bugs.python.org/issue4265> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com