gyp: Python 3 Windows fixes

PR-URL: https://github.com/nodejs/node-gyp/pull/1843
Reviewed-By: Christian Clauss <cclauss@me.com>
Reviewed-By: Rod Vagg <r@va.gg>
Reviewed-By: Matt Cowley <me@mattcowley.co.uk>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
This commit is contained in:
João Reis 2019-07-23 16:02:09 +01:00
parent a2a862f6ba
commit 2592036261
5 changed files with 10 additions and 11 deletions

View file

@ -45,7 +45,7 @@ def MakeGuid(name, seed='msvs_new'):
not change when the project for a target is rebuilt.
"""
# Calculate a MD5 signature for the seed and name.
d = hashlib.md5(str(seed) + str(name)).hexdigest().upper()
d = hashlib.md5((str(seed) + str(name)).encode('utf-8')).hexdigest().upper()
# Convert most of the signature to GUID form (discard the rest)
guid = ('{' + d[:8] + '-' + d[8:12] + '-' + d[12:16] + '-' + d[16:20]
+ '-' + d[20:32] + '}')

View file

@ -394,6 +394,9 @@ def WriteOnDiff(filename):
os.unlink(self.tmp_path)
raise
def write(self, s):
self.tmp_file.write(s.encode('utf-8'))
return Writer()

View file

@ -120,7 +120,7 @@ def WriteXmlIfChanged(content, path, encoding='utf-8', pretty=False,
default_encoding = locale.getdefaultlocale()[1]
if default_encoding.upper() != encoding.upper():
xml_string = xml_string.decode(default_encoding).encode(encoding)
xml_string = xml_string.encode(encoding)
# Get the old content
try:
@ -132,7 +132,7 @@ def WriteXmlIfChanged(content, path, encoding='utf-8', pretty=False,
# It has changed, write it
if existing != xml_string:
f = open(path, 'w')
f = open(path, 'wb')
f.write(xml_string)
f.close()

View file

@ -1753,8 +1753,8 @@ def _CollapseSingles(parent, node):
# such projects up one level.
if (type(node) == dict and
len(node) == 1 and
node.keys()[0] == parent + '.vcproj'):
return node[node.keys()[0]]
list(node)[0] == parent + '.vcproj'):
return node[list(node)[0]]
if type(node) != dict:
return node
for child in node:
@ -1773,8 +1773,8 @@ def _GatherSolutionFolders(sln_projects, project_objects, flat):
# Walk down from the top until we hit a folder that has more than one entry.
# In practice, this strips the top-level "src/" dir from the hierarchy in
# the solution.
while len(root) == 1 and type(root[root.keys()[0]]) == dict:
root = root[root.keys()[0]]
while len(root) == 1 and type(root[list(root)[0]]) == dict:
root = root[list(root)[0]]
# Collapse singles.
root = _CollapseSingles('', root)
# Merge buckets until everything is a root entry.