Message105079
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. |
|
Date |
User |
Action |
Args |
2010-05-05 19:34:50 | ammon_riley | set | recipients:
+ ammon_riley, tseaver, pitrou, vstinner, tarek |
2010-05-05 19:34:50 | ammon_riley | set | messageid: <1273088090.42.0.399430807086.issue4265@psf.upfronthosting.co.za> |
2010-05-05 19:34:48 | ammon_riley | link | issue4265 messages |
2010-05-05 19:34:48 | ammon_riley | create | |
|