mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
[scaleway inventory] Fix JSON object must be str, not 'bytes' (#2771)
* Fix JSON object decoding * Code improvement : python 3.5 fix * Add changelog fragment * Update changelogs/fragments/2771-scaleway_inventory_json_accept_byte_array.yml Co-authored-by: Felix Fontein <felix@fontein.de> Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
f44300cec5
commit
c2ce7a0752
2 changed files with 5 additions and 2 deletions
|
@ -0,0 +1,3 @@
|
||||||
|
bugfixes:
|
||||||
|
- scaleway plugin inventory - fix ``JSON object must be str, not 'bytes'`` with Python 3.5
|
||||||
|
(https://github.com/ansible-collections/community.general/issues/2769).
|
|
@ -89,7 +89,7 @@ from ansible.errors import AnsibleError
|
||||||
from ansible.plugins.inventory import BaseInventoryPlugin, Constructable
|
from ansible.plugins.inventory import BaseInventoryPlugin, Constructable
|
||||||
from ansible_collections.community.general.plugins.module_utils.scaleway import SCALEWAY_LOCATION, parse_pagination_link
|
from ansible_collections.community.general.plugins.module_utils.scaleway import SCALEWAY_LOCATION, parse_pagination_link
|
||||||
from ansible.module_utils.urls import open_url
|
from ansible.module_utils.urls import open_url
|
||||||
from ansible.module_utils._text import to_native
|
from ansible.module_utils._text import to_native, to_text
|
||||||
|
|
||||||
import ansible.module_utils.six.moves.urllib.parse as urllib_parse
|
import ansible.module_utils.six.moves.urllib.parse as urllib_parse
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ def _fetch_information(token, url):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise AnsibleError("Error while fetching %s: %s" % (url, to_native(e)))
|
raise AnsibleError("Error while fetching %s: %s" % (url, to_native(e)))
|
||||||
try:
|
try:
|
||||||
raw_json = json.loads(response.read())
|
raw_json = json.loads(to_text(response.read()))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise AnsibleError("Incorrect JSON payload")
|
raise AnsibleError("Incorrect JSON payload")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue