1
0
Fork 0
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) (#2783)

* 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>
(cherry picked from commit c2ce7a0752)

Co-authored-by: Loïc <loic.latreille@gmail.com>
This commit is contained in:
patchback[bot] 2021-06-11 13:23:41 +02:00 committed by GitHub
parent ffdef00a6a
commit 725e670b47
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View file

@ -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).

View file

@ -89,7 +89,7 @@ from ansible.errors import AnsibleError
from ansible.plugins.inventory import BaseInventoryPlugin, Constructable
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._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
@ -105,7 +105,7 @@ def _fetch_information(token, url):
except Exception as e:
raise AnsibleError("Error while fetching %s: %s" % (url, to_native(e)))
try:
raw_json = json.loads(response.read())
raw_json = json.loads(to_text(response.read()))
except ValueError:
raise AnsibleError("Incorrect JSON payload")