1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-06-11 18:45:34 +00:00

xml: false positive python2 string type check bugfix (#12108)

* bugfixes:
  - xml: fix false positive type check failure for string values on Python 2
    hosts, where ``json_dict_bytes_to_unicode`` guarantees unicode output but
    ``isinstance(value, str)`` only matches byte strings.

* changelog fragment for xml false positive type check failure.

* Rename xml-python2-string-isinstance to 12108-fix-xml-python2-string-isinstance

* Rename 12108-fix-xml-python2-string-isinstance to 12108-fix-xml-python2-string-isinstance.yml

* Update changelogs/fragments/12108-fix-xml-python2-string-isinstance.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
RoboticInterface 2026-05-28 14:52:24 -05:00 committed by GitHub
parent ae76a908d6
commit be9afb4800
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 1 deletions

View file

@ -0,0 +1,5 @@
bugfixes:
- xml - fix false positive type check failure for string values on Python 2
hosts, where ``json_dict_bytes_to_unicode`` guarantees unicode output but
``isinstance(value, str)`` only matches byte strings
(https://github.com/ansible-collections/community.general/issues/12107, https://github.com/ansible-collections/community.general/pull/12108).

View file

@ -689,7 +689,7 @@ def set_target_inner(module, tree, xpath, namespaces, attribute, value):
module.fail_json(msg="Xpath %s does not reference a node! tree is %s" %
(xpath, etree.tostring(tree, pretty_print=True)))
if not isinstance(value, str):
if not isinstance(value, string_types):
target = ("attribute '{attribute}' at xpath '{xpath}'" if attribute else "element text at xpath '{xpath}'").format(attribute=attribute, xpath=xpath)
module.fail_json(
msg=(