def catch_exceptions_if_in_safe_mode(function):
 def wrapped(method, url, **kwargs):
  if ((kwargs.get('config') and kwargs.get('config').get('safe_mode')) or (kwargs.get('session') and kwargs.get('session').config.get('safe_mode'))):
   try:
    return function(method, url, **kwargs)
   except (RequestException, ConnectionError, HTTPError, socket.timeout, socket.gaierror) as e:
    r = Response()
    r.error = e
    r.raw = HTTPResponse()
    r.status_code = 0
    return r
  return function(method, url, **kwargs)
 return wrapped

def catch_exceptions_if_in_safe_mode ( function ) : def wrapped ( method , url , ** kwargs ) : if ( ( kwargs . get ( 'config' ) and kwargs . get ( 'config' ) . get ( 'safe_mode' ) ) or ( kwargs . get ( 'session' ) and kwargs . get ( 'session' ) . config . get ( 'safe_mode' ) ) ) : try : return function ( method , url , ** kwargs ) except ( RequestException , ConnectionError , HTTPError , socket . timeout , socket . gaierror ) as e : r = Response ( ) r . error = e r . raw = HTTPResponse ( ) r . status_code = 0 return r return function ( method , url , ** kwargs ) return wrapped
new implementation of safe_mode .