mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
Fix for #804 - Session params ommited in 0.13.8. If default_kwarg is a list, attempt to convert to dictionary
This commit is contained in:
+11
-2
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user