From: Andrew Tolbert Date: Wed, 22 Aug 2012 14:49:40 +0000 (-0500) Subject: Fix for #804 - Session params ommited in 0.13.8. If default_kwarg is a list, attempt... X-Git-Tag: upstream/2.2.1~474^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f18733d2be4a9c3d0d3ceea31be9e191c05f21d6;p=platform%2Fupstream%2Fpython-requests.git Fix for #804 - Session params ommited in 0.13.8. If default_kwarg is a list, attempt to convert to dictionary --- diff --git a/requests/sessions.py b/requests/sessions.py index cd05490..1f46688 100644 --- a/requests/sessions.py +++ b/requests/sessions.py @@ -34,14 +34,23 @@ def merge_kwargs(local_kwarg, default_kwarg): if local_kwarg is None: return default_kwarg + kwargs = default_kwarg + # If default_kwargs is a list rather than a dictionary attempt to convert + # to dictionary. If the check fails, return local_kwargs. + if isinstance(default_kwarg, list): + try: + kwargs = dict(kwargs) + except ValueError: + return local_kwarg + # Bypass if not a dictionary (e.g. timeout) - if not hasattr(default_kwarg, 'items'): + if not hasattr(kwargs, 'items'): return local_kwarg local_kwarg = to_key_val_list(local_kwarg) # Update new values. - kwargs = default_kwarg.copy() + kwargs = kwargs.copy() kwargs.update(local_kwarg) # Remove keys that are set to None.