Skip to content
Myr

remove safe mode

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Kenneth Reitz · committed by Kenneth Reitz · parent 1607a6a · Browse files · 3 files+0 added−45 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+0 added−45 removed

  • other:+0 added−45 removed

3 files+0 added−45 removed

modified:requests/defaults.py-3 removed
37 unmodified lines
38defaults['max_redirects'] = 3039defaults['pool_connections'] = 1040defaults['pool_maxsize'] = 1041defaults['max_retries'] = 042defaults['danger_mode'] = False43defaults['safe_mode'] = False44defaults['strict_mode'] = False42defaults['keep_alive'] = True43defaults['encode_uri'] = True44defaults['trust_env'] = True45defaults['store_cookies'] = True
deleted:requests/safe_mode.py-40 removed
1# -*- coding: utf-8 -*-23"""4requests.safe_mode5~~~~~~~~~~~~67This module contains a decorator that implements safe_mode.89:copyright: (c) 2012 by Kenneth Reitz.10:license: ISC, see LICENSE for more details.1112"""1314from .models import Response15from .packages.urllib3.response import HTTPResponse16from .exceptions import RequestException, ConnectionError, HTTPError17import socket181920def catch_exceptions_if_in_safe_mode(function):21 """New implementation of safe_mode. We catch all exceptions at the Session level22 and then return a blank Response object with the error field filled. This decorator23 wraps Session._send_request() in sessions.py.24 """2526 def wrapped(*args, **kwargs):27 # if save_mode, we catch exceptions and fill error field28 if (kwargs.get('config') and kwargs.get('config').get('safe_mode')) or (kwargs.get('session')29 and kwargs.get('session').config.get('safe_mode')):30 try:31 return function(*args, **kwargs)32 except (RequestException, ConnectionError, HTTPError,33 socket.timeout, socket.gaierror) as e:34 r = Response()35 r.error = e36 r.raw = HTTPResponse() # otherwise, tests fail37 r.status_code = 0 # with this status_code, content returns None38 return r39 return function(*args, **kwargs)40 return wrapped
modified:requests/sessions.py-2 removed
15 unmodified lines
16from .models import Request17from .hooks import dispatch_hook18from .utils import header_expand, from_key_val_list19from .packages.urllib3.poolmanager import PoolManager20from .safe_mode import catch_exceptions_if_in_safe_mode202122def merge_kwargs(local_kwarg, default_kwarg):23 """Merges kwarg dictionaries.
242 unmodified lines
266267 # Send the HTTP Request.268 return self._send_request(r, **args)269271 @catch_exceptions_if_in_safe_mode270 def _send_request(self, r, **kwargs):271 # Send the request.272 r.send(prefetch=kwargs.get("prefetch"))273
86 unmodified lines