]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-43651: Fix EncodingWarning in sysconfig (GH-25192)
authorInada Naoki <songofacandy@gmail.com>
Tue, 6 Apr 2021 01:01:11 +0000 (10:01 +0900)
committerGitHub <noreply@github.com>
Tue, 6 Apr 2021 01:01:11 +0000 (10:01 +0900)
Lib/sysconfig.py

index 507c51f7642376be33b314aa8ff16e1ad18505c6..b8b1aca17e24d9e199c215ab5db1d7dbe125a93b 100644 (file)
@@ -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