Raymond Hettinger added the comment:
Hmm, the __exit__ method was doing exact matches by exception type, so KeyError
wouldn't match LookupError or Exception.
There are probably a number of ways to fix this, but it may be easiest to use
the builtin exception catching mechanisms:
class Ignore:
''' Context manager to ignore particular exceptions'''
def __init__(self, *ignored_exceptions):
self.ignored_exceptions = ignored_exceptions
def __enter__(self):
return self
def __exit__(self, exctype, excinst, exctb):
if exctype is not None:
try:
raise
except self.ignored_exceptions:
return True
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue15806>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com