[Python-checkins] Fix EncodingWarning in Tools/freeze/test/freeze.py (GH-29742)

methane webhook-mailer at python.org
Mon Nov 29 23:16:48 EST 2021


https://github.com/python/cpython/commit/9a5dec4e978f68ab956e979858ce3aa178436fa4
commit: 9a5dec4e978f68ab956e979858ce3aa178436fa4
branch: main
author: Inada Naoki <songofacandy at gmail.com>
committer: methane <songofacandy at gmail.com>
date: 2021-11-30T13:16:40+09:00
summary:

Fix EncodingWarning in Tools/freeze/test/freeze.py (GH-29742)

files:
M Tools/freeze/test/freeze.py

diff --git a/Tools/freeze/test/freeze.py b/Tools/freeze/test/freeze.py
index db2aa3101d879..abedac03f91b0 100644
--- a/Tools/freeze/test/freeze.py
+++ b/Tools/freeze/test/freeze.py
@@ -89,7 +89,7 @@ def get_makefile_var(builddir, name):
     regex = re.compile(rf'^{name} *=\s*(.*?)\s*$')
     filename = os.path.join(builddir, 'Makefile')
     try:
-        infile = open(filename)
+        infile = open(filename, encoding='utf-8')
     except FileNotFoundError:
         return None
     with infile:
@@ -125,7 +125,7 @@ def prepare(script=None, outdir=None):
     if script:
         scriptfile = os.path.join(outdir, 'app.py')
         print(f'creating the script to be frozen at {scriptfile}')
-        with open(scriptfile, 'w') as outfile:
+        with open(scriptfile, 'w', encoding='utf-8') as outfile:
             outfile.write(script)
 
     # Make a copy of the repo to avoid affecting the current build



More information about the Python-checkins mailing list