try:
[...]
except IOError:
# Worst-case scenario we can only catch errors at a granularity
# of the whole function.
[...]
else:
# If we have access to the source, we can silence errors on a
# per-expression basis, which is "better".
[...]
and then:
def __exit__(self, exc_type, exc_value, traceback):
# Returning True prevents the error from propagating. Don't silence
# KeyboardInterrupt or SystemExit. We aren't monsters.