[PR #11098/634be713 backport][stable-12] replace batch of redundant to_native() occurrences (#11100)

replace batch of redundant to_native() occurrences (#11098)

* replace batch of redundant to_native() occurrences

* add changelog frag

(cherry picked from commit 634be713bb)

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
patchback[bot]
2025-11-11 07:23:07 +01:00
committed by GitHub
parent 5be39ee0c3
commit d487734fea
63 changed files with 164 additions and 157 deletions

View File

@@ -90,7 +90,6 @@ else:
pyodbc_found = True
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
from ansible.module_utils.common.text.converters import to_native
class NotSupportedError(Exception):
@@ -227,21 +226,21 @@ def main():
try:
changed = absent(role_facts, cursor, role, assigned_roles)
except pyodbc.Error as e:
module.fail_json(msg=to_native(e), exception=traceback.format_exc())
module.fail_json(msg=f"{e}", exception=traceback.format_exc())
elif state == "present":
try:
changed = present(role_facts, cursor, role, assigned_roles)
except pyodbc.Error as e:
module.fail_json(msg=to_native(e), exception=traceback.format_exc())
module.fail_json(msg=f"{e}", exception=traceback.format_exc())
except NotSupportedError as e:
module.fail_json(msg=to_native(e), ansible_facts={"vertica_roles": role_facts})
module.fail_json(msg=f"{e}", ansible_facts={"vertica_roles": role_facts})
except CannotDropError as e:
module.fail_json(msg=to_native(e), ansible_facts={"vertica_roles": role_facts})
module.fail_json(msg=f"{e}", ansible_facts={"vertica_roles": role_facts})
except SystemExit:
# avoid catching this on python 2.4
raise
except Exception as e:
module.fail_json(msg=to_native(e), exception=traceback.format_exc())
module.fail_json(msg=f"{e}", exception=traceback.format_exc())
module.exit_json(changed=changed, role=role, ansible_facts={"vertica_roles": role_facts})