From c46e7ca79d6262082ce66b91c0895801c20abd38 Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Mon, 5 Apr 2021 22:37:57 +0900 Subject: [PATCH] bpo-43651: Fix EncodingWarning in sysconfig --- Lib/sysconfig.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py index 507c51f7642376..b8b1aca17e24d9 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