Skip to content

Commit

Permalink
fix: decode string to string
Browse files Browse the repository at this point in the history
github-close-issue:  2505
  • Loading branch information
owl-from-hogvarts committed Jul 31, 2022
1 parent b1119d5 commit cb7b53c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions gyp/pylib/gyp/easy_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ def WriteXmlIfChanged(content, path, encoding="utf-8", pretty=False, win32=False

default_encoding = locale.getdefaultlocale()[1]
if default_encoding and default_encoding.upper() != encoding.upper():
if sys.platform == "win32" and sys.version_info < (3, 7):
xml_string = xml_string.decode("cp1251").encode(encoding)
else:
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 cb7b53c

Please sign in to comment.