@contextlib.contextmanager
def force_error_model(context, model_name='numpy'):
 from . import callconv
 old_error_model = context.error_model
 context.error_model = callconv.create_error_model(model_name, context)
 try:
  (yield)
 finally:
  context.error_model = old_error_model

@ contextlib . contextmanager def force_error_model ( context , model_name = 'numpy' ) : from . import callconv old_error_model = context . error_model context . error_model = callconv . create_error_model ( model_name , context ) try : ( yield ) finally : context . error_model = old_error_model
temporarily change the contexts error model .