Fix for #804 - Session params ommited in 0.13.8. If default_kwarg is a list, attempt...
authorAndrew Tolbert <x@andrewtolbert.com>
Wed, 22 Aug 2012 14:49:40 +0000 (09:49 -0500)
committerAndrew Tolbert <x@andrewtolbert.com>
Wed, 22 Aug 2012 14:49:40 +0000 (09:49 -0500)
requests/sessions.py

index cd05490..1f46688 100644 (file)
@@ -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.