session improvements

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>
This commit is contained in:
2018-03-15 16:53:25 -04:00
parent c4a2e88436
commit 2aa9d23a91
2 changed files with 4 additions and 13 deletions
+4 -11
View File
@@ -353,7 +353,7 @@ class Session(SessionRedirectMixin):
>>> s.get('http://httpbin.org/get')
<Response [200]>
"""
__attrs__ = [
__slots__ = [
'headers',
'cookies',
'auth',
@@ -369,6 +369,8 @@ class Session(SessionRedirectMixin):
'max_redirects',
]
__slots__
def __init__(self):
# : A case-insensitive dictionary of headers to be sent on each
#: :class:`Request <Request>` sent from this
@@ -735,18 +737,9 @@ class Session(SessionRedirectMixin):
self.adapters[key] = self.adapters.pop(key)
def __getstate__(self):
state = {attr: getattr(self, attr, None) for attr in self.__attrs__}
state = {attr: getattr(self, attr, None) for attr in self.__slots__}
return state
def __setstate__(self, state):
for attr, value in state.items():
setattr(self, attr, value)
def session():
"""
Returns a :class:`Session` for context-management.
:rtype: Session
"""
return Session()
-2
View File
@@ -37,7 +37,6 @@ class CaseInsensitiveDict(collections.MutableMapping):
operations are given keys that have equal ``.lower()``s, the
behavior is undefined.
"""
__slots__ = ('_store')
def __init__(self, data=None, **kwargs):
@@ -98,7 +97,6 @@ class HTTPHeaderDict(CaseInsensitiveDict):
self.extend({} if data is None else data, **kwargs)
#
# We'll store tuples in the internal dictionary, but present them as a
# concatenated string when we use item access methods.
#