Skip to content

Commit 67393c1

Browse files
fix: decode bytes not str
proper fix for #118 Special thanks to @cclauss
1 parent baef940 commit 67393c1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pylib/gyp/easy_xml.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,10 @@ def WriteXmlIfChanged(content, path, encoding="utf-8", pretty=False,
123123

124124
default_encoding = locale.getdefaultlocale()[1]
125125
if default_encoding and default_encoding.upper() != encoding.upper():
126-
xml_string = xml_string.encode(encoding)
126+
if sys.platform == "win32":
127+
if isinstance(xml_string, str):
128+
xml_string = xml_string.decode("cp1251") # str --> bytes
129+
xml_string = xml_string.encode(encoding) # bytes --> str
127130

128131
# Get the old content
129132
try:

0 commit comments

Comments
 (0)