mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-26 12:21:26 -07:00
Fall back to ValueError if JSONDecodeError is not available (#38276)
This commit is contained in:
parent
7afa34ae8a
commit
e05cad785e
2 changed files with 4 additions and 2 deletions
|
@ -913,7 +913,8 @@ class TaskExecutor:
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
result = json.loads(to_text(stderr, errors='surrogate_then_replace'))
|
result = json.loads(to_text(stderr, errors='surrogate_then_replace'))
|
||||||
except json.decoder.JSONDecodeError:
|
except getattr(json.decoder, 'JSONDecodeError', ValueError):
|
||||||
|
# JSONDecodeError only available on Python 3.5+
|
||||||
result = {'error': to_text(stderr, errors='surrogate_then_replace')}
|
result = {'error': to_text(stderr, errors='surrogate_then_replace')}
|
||||||
|
|
||||||
if 'messages' in result:
|
if 'messages' in result:
|
||||||
|
|
|
@ -115,7 +115,8 @@ class Connection(ConnectionBase):
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
result = json.loads(to_text(stderr, errors='surrogate_then_replace'))
|
result = json.loads(to_text(stderr, errors='surrogate_then_replace'))
|
||||||
except json.decoder.JSONDecodeError:
|
except getattr(json.decoder, 'JSONDecodeError', ValueError):
|
||||||
|
# JSONDecodeError only available on Python 3.5+
|
||||||
result = {'error': to_text(stderr, errors='surrogate_then_replace')}
|
result = {'error': to_text(stderr, errors='surrogate_then_replace')}
|
||||||
|
|
||||||
if 'messages' in result:
|
if 'messages' in result:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue