From e0c0ad4e1cab2a91227da490f97d553d9fc54f93 Mon Sep 17 00:00:00 2001 From: owl-from-hogvarts Date: Sun, 31 Jul 2022 11:59:54 +0300 Subject: [PATCH] fix: decode bytes not str proper fix for #118 Special thanks to @cclauss --- pylib/gyp/easy_xml.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pylib/gyp/easy_xml.py b/pylib/gyp/easy_xml.py index bda1a474..41fb3c7c 100644 --- a/pylib/gyp/easy_xml.py +++ b/pylib/gyp/easy_xml.py @@ -123,7 +123,10 @@ def WriteXmlIfChanged(content, path, encoding="utf-8", pretty=False, default_encoding = locale.getdefaultlocale()[1] if default_encoding and default_encoding.upper() != encoding.upper(): - xml_string = xml_string.encode(encoding) + if sys.platform == "win32": + if isinstance(xml_string, str): + xml_string = xml_string.decode("cp1251") # str --> bytes + xml_string = xml_string.encode(encoding) # bytes --> str # Get the old content try: