@contextlib.contextmanager<EOL>def rewrite_exception(old_name, new_name):
try:<EOL><INDENT>yield<EOL><DEDENT>except Exception as e:<EOL><INDENT>msg = e.args[<NUM_LIT:0>]<EOL>msg = msg.replace(old_name, new_name)<EOL>args = (msg,)<EOL>if len(e.args) > <NUM_LIT:1>:<EOL><INDENT>args = args + e.args[<NUM_LIT:1>:]<EOL><DEDENT>e.args = args<EOL>raise<EOL><DEDENT>
Rewrite the message of an exception.