diff --git a/requests/sessions.py b/requests/sessions.py index a4ca2719..659c1f06 100644 --- a/requests/sessions.py +++ b/requests/sessions.py @@ -353,7 +353,7 @@ class Session(SessionRedirectMixin): >>> s.get('http://httpbin.org/get') """ - __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 ` 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() diff --git a/requests/structures.py b/requests/structures.py index 59d4645e..c88d744d 100644 --- a/requests/structures.py +++ b/requests/structures.py @@ -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. #