From 072bee9c5d18a77fd25afffec036586772d0d1a7 Mon Sep 17 00:00:00 2001 From: Adrian Vladu Date: Mon, 21 Nov 2022 19:29:53 +0200 Subject: [PATCH] xml: force return of unicode string With Python 3.8, the xml.etree.ElementTree.ElementTree function now preserves the attribute order specified by the user. This change broke the winrm enable functionality, throwing the erorr: ``` TypeError: Objects of type 'bytes' can not be converted to Unicode. ``` The fix was to set the correct parameter to return an unicode string and not bytes. Change-Id: I10f7fa357267f36dfed03ccb708694f6fc1cdd97 --- cloudbaseinit/utils/windows/winrmconfig.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloudbaseinit/utils/windows/winrmconfig.py b/cloudbaseinit/utils/windows/winrmconfig.py index fe7e8410..5f28fafa 100644 --- a/cloudbaseinit/utils/windows/winrmconfig.py +++ b/cloudbaseinit/utils/windows/winrmconfig.py @@ -191,5 +191,5 @@ class WinRMConfig(object): new_value = self._get_xml_bool(value) if node.text.lower() != new_value: node.text = new_value - data_xml = ElementTree.tostring(tree) + data_xml = ElementTree.tostring(tree, encoding="unicode") session.Put(self._SERVICE_AUTH_URI, data_xml)