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 37814ec commit 6169230
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 @@ -123,10 +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():
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 6169230

Please sign in to comment.