]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix EncodingWarning in freeze_modules. (GH-28591)
authorInada Naoki <songofacandy@gmail.com>
Thu, 30 Sep 2021 03:36:16 +0000 (12:36 +0900)
committerGitHub <noreply@github.com>
Thu, 30 Sep 2021 03:36:16 +0000 (12:36 +0900)
Tools/scripts/freeze_modules.py

index f7273915b911e2c9ab5a33795229deb37059132d..ea96253df3e49335a23950415147452037004b29 100644 (file)
@@ -329,10 +329,10 @@ def _iter_sources(modules):
 # generic helpers
 
 def _get_checksum(filename):
-    with open(filename) as infile:
-        text = infile.read()
+    with open(filename, "rb") as infile:
+        contents = infile.read()
     m = hashlib.sha256()
-    m.update(text.encode('utf8'))
+    m.update(contents)
     return m.hexdigest()
 
 
@@ -489,7 +489,7 @@ def regen_manifest(modules):
         modlines.append(' '.join(row).rstrip())
 
     print(f'# Updating {os.path.relpath(MANIFEST)}')
-    with open(MANIFEST, 'w') as outfile:
+    with open(MANIFEST, 'w', encoding="utf-8") as outfile:
         lines = (l + '\n' for l in modlines)
         outfile.writelines(lines)