summaryrefslogtreecommitdiff
path: root/lib/ansible/module_utils/urls.py
diff options
context:
space:
mode:
authorToshio Kuratomi <a.badger@gmail.com>2017-03-24 12:24:59 -0700
committerGitHub <noreply@github.com>2017-03-24 12:24:59 -0700
commit29f623571eace54afc98e966c0e1ca66a19d03f2 (patch)
treecb20c666784c2cf2d3636169582e7a500a48e063 /lib/ansible/module_utils/urls.py
parent6cea89299a515c7bc4a70611edd10dbe103d92eb (diff)
downloadansible-29f623571eace54afc98e966c0e1ca66a19d03f2.tar.gz
Handle the case where HTTPError.info() returns an object that aren't (#22894)
dict-like enough (can't be used with **). This should give a better error message for #22872
Diffstat (limited to 'lib/ansible/module_utils/urls.py')
-rw-r--r--lib/ansible/module_utils/urls.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/ansible/module_utils/urls.py b/lib/ansible/module_utils/urls.py
index ac60ee260a..f3c3b635fd 100644
--- a/lib/ansible/module_utils/urls.py
+++ b/lib/ansible/module_utils/urls.py
@@ -1009,8 +1009,16 @@ def fetch_url(module, url, data=None, headers=None, method=None,
body = e.read()
except AttributeError:
body = ''
- info.update(dict(msg=str(e), body=body, **e.info()))
- info['status'] = e.code
+
+ # Try to add exception info to the output but don't fail if we can't
+ exc_info = e.info()
+ try:
+ info.update(dict(**e.info()))
+ except:
+ pass
+
+ info.update({'msg': str(e), 'body': body, 'status': e.code})
+
except urllib_error.URLError:
e = get_exception()
code = int(getattr(e, 'code', -1))