[Python-checkins] bpo-43651: Fix EncodingWarning in sysconfig (GH-25192)

methane webhook-mailer at python.org
Mon Apr 5 21:01:24 EDT 2021


https://github.com/python/cpython/commit/3d4af4a876e679431c6a3751667ded63cc6f66c1
commit: 3d4af4a876e679431c6a3751667ded63cc6f66c1
branch: master
author: Inada Naoki <songofacandy at gmail.com>
committer: methane <songofacandy at gmail.com>
date: 2021-04-06T10:01:11+09:00
summary:

bpo-43651: Fix EncodingWarning in sysconfig (GH-25192)

files:
M Lib/sysconfig.py

diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py
index 507c51f764237..b8b1aca17e24d 100644
--- a/Lib/sysconfig.py
+++ b/Lib/sysconfig.py
@@ -240,7 +240,8 @@ def _parse_makefile(filename, vars=None):
     done = {}
     notdone = {}
 
-    with open(filename, errors="surrogateescape") as f:
+    with open(filename, encoding=sys.getfilesystemencoding(),
+              errors="surrogateescape") as f:
         lines = f.readlines()
 
     for line in lines:
@@ -388,7 +389,7 @@ def _generate_posix_vars():
     # load the installed pyconfig.h:
     config_h = get_config_h_filename()
     try:
-        with open(config_h) as f:
+        with open(config_h, encoding="utf-8") as f:
             parse_config_h(f, vars)
     except OSError as e:
         msg = "invalid Python installation: unable to open %s" % config_h



More information about the Python-checkins mailing list