Skip to content

Commit

Permalink
fix: decode bytes not str
Browse files Browse the repository at this point in the history
proper fix for nodejs#118
Special thanks to @cclauss
  • Loading branch information
owl-from-hogvarts committed Jul 31, 2022
1 parent 1f421c9 commit e0c0ad4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pylib/gyp/easy_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit e0c0ad4

Please sign in to comment.