From 31f0087da97512909aa46a4a49577e8547e59967 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Wed, 12 Nov 2025 21:58:55 +0100 Subject: [PATCH] [PR #11104/4171b8a9 backport][stable-12] replace batch of redundant to_native()/to_text() occurrences (#11138) replace batch of redundant to_native()/to_text() occurrences (#11104) * replace batch of redundant to_native()/to_text() occurrences * add changelog frag (cherry picked from commit 4171b8a9ab6aa2b21b32774279660d38efb13c9e) Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> --- changelogs/fragments/11104-tonative-3.yml | 6 ++++++ plugins/modules/filesize.py | 3 +-- plugins/modules/ip_netns.py | 3 +-- plugins/modules/ipa_subca.py | 3 +-- plugins/modules/jira.py | 2 +- plugins/modules/ldap_search.py | 4 ++-- 6 files changed, 12 insertions(+), 9 deletions(-) create mode 100644 changelogs/fragments/11104-tonative-3.yml diff --git a/changelogs/fragments/11104-tonative-3.yml b/changelogs/fragments/11104-tonative-3.yml new file mode 100644 index 0000000000..bc365424f1 --- /dev/null +++ b/changelogs/fragments/11104-tonative-3.yml @@ -0,0 +1,6 @@ +minor_changes: + - filesize - remove redundant conversions to unicode (https://github.com/ansible-collections/community.general/pull/11104). + - ip_netns - remove redundant conversions to unicode (https://github.com/ansible-collections/community.general/pull/11104). + - ipa_subca - remove redundant conversions to unicode (https://github.com/ansible-collections/community.general/pull/11104). + - jira - remove redundant conversions to unicode (https://github.com/ansible-collections/community.general/pull/11104). + - ldap_search - remove redundant conversions to unicode (https://github.com/ansible-collections/community.general/pull/11104). diff --git a/plugins/modules/filesize.py b/plugins/modules/filesize.py index d61f9c11db..7ab199bad1 100644 --- a/plugins/modules/filesize.py +++ b/plugins/modules/filesize.py @@ -219,7 +219,6 @@ import os import math from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.common.text.converters import to_native # These are the multiplicative suffixes understood (or returned) by dd and @@ -453,7 +452,7 @@ def main(): initial_filesize = current_size(args) size_descriptors = size_spec(args) except AssertionError as err: - module.fail_json(msg=to_native(err)) + module.fail_json(msg=f"{err}") expected_filesize = size_descriptors["bytes"] if initial_filesize: diff --git a/plugins/modules/ip_netns.py b/plugins/modules/ip_netns.py index 0666e8670f..29d05f87cc 100644 --- a/plugins/modules/ip_netns.py +++ b/plugins/modules/ip_netns.py @@ -49,7 +49,6 @@ RETURN = r""" """ from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.common.text.converters import to_text class Namespace: @@ -68,7 +67,7 @@ class Namespace: """Check if the namespace already exists""" rc, out, err = self.module.run_command(["ip", "netns", "list"]) if rc != 0: - self.module.fail_json(msg=to_text(err)) + self.module.fail_json(msg=f"{err}") return self.name in out def add(self): diff --git a/plugins/modules/ipa_subca.py b/plugins/modules/ipa_subca.py index 68d26e6fa1..af77462695 100644 --- a/plugins/modules/ipa_subca.py +++ b/plugins/modules/ipa_subca.py @@ -79,7 +79,6 @@ subca: from ansible.module_utils.basic import AnsibleModule from ansible_collections.community.general.plugins.module_utils.ipa import IPAClient, ipa_argument_spec -from ansible.module_utils.common.text.converters import to_native from ansible_collections.community.general.plugins.module_utils.version import LooseVersion @@ -215,7 +214,7 @@ def main(): changed, record = ensure(module, client) module.exit_json(changed=changed, record=record) except Exception as exc: - module.fail_json(msg=to_native(exc)) + module.fail_json(msg=f"{exc}") if __name__ == "__main__": diff --git a/plugins/modules/jira.py b/plugins/modules/jira.py index efa991eba1..a51393b2ca 100644 --- a/plugins/modules/jira.py +++ b/plugins/modules/jira.py @@ -841,7 +841,7 @@ class JIRA(StateModuleHelper): msg.append(to_native(error[key])) if msg: self.module.fail_json(msg=", ".join(msg)) - self.module.fail_json(msg=to_native(error)) + self.module.fail_json(msg=f"{error}") # Fallback print body, if it can't be decoded self.module.fail_json(msg=to_native(info["body"])) diff --git a/plugins/modules/ldap_search.py b/plugins/modules/ldap_search.py index cc6fe4c8ff..1bdd8d5d19 100644 --- a/plugins/modules/ldap_search.py +++ b/plugins/modules/ldap_search.py @@ -107,7 +107,7 @@ import base64 import traceback from ansible.module_utils.basic import AnsibleModule, missing_required_lib -from ansible.module_utils.common.text.converters import to_bytes, to_native, to_text +from ansible.module_utils.common.text.converters import to_bytes, to_text from ansible_collections.community.general.plugins.module_utils.ldap import ( LdapGeneric, gen_specs, @@ -145,7 +145,7 @@ def main(): try: LdapSearch(module).main() except Exception as exception: - module.fail_json(msg="Attribute action failed.", details=to_native(exception)) + module.fail_json(msg="Attribute action failed.", details=f"{exception}") def _normalize_string(val, convert_to_base64):