From 1a9990a92f5986a7ed8baf8eca3f211b1e482558 Mon Sep 17 00:00:00 2001 From: Kevin Phoenix Date: Tue, 28 Feb 2023 12:46:10 -0700 Subject: [PATCH] Use sys.getdefaultencoding() instead of sys.stdout.encoding (#6612) --- doc/mk_params_doc.py | 4 ++-- doc/mk_tactic_doc.py | 2 +- scripts/mk_util.py | 2 +- scripts/update_api.py | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/mk_params_doc.py b/doc/mk_params_doc.py index de527641649..021cab3c35e 100644 --- a/doc/mk_params_doc.py +++ b/doc/mk_params_doc.py @@ -37,7 +37,7 @@ def help(ous): out = subprocess.Popen([z3_exe, "-pm"],stdout=subprocess.PIPE).communicate()[0] modules = ["global"] if out != None: - out = out.decode(sys.stdout.encoding) + out = out.decode(sys.getdefaultencoding()) module_re = re.compile(r"\[module\] (.*)\,") lines = out.split("\n") for line in lines: @@ -48,7 +48,7 @@ def help(ous): out = subprocess.Popen([z3_exe, "-pmmd:%s" % module],stdout=subprocess.PIPE).communicate()[0] if out == None: continue - out = out.decode(sys.stdout.encoding) + out = out.decode(sys.getdefaultencoding()) out = out.replace("\r","") ous.write(out) diff --git a/doc/mk_tactic_doc.py b/doc/mk_tactic_doc.py index a22201e2712..804df2f7e19 100644 --- a/doc/mk_tactic_doc.py +++ b/doc/mk_tactic_doc.py @@ -28,7 +28,7 @@ def extract_params(ous, tac): out = subprocess.Popen([z3_exe, f"-tacticsmd:{tac}"], stdout=subprocess.PIPE).communicate()[0] if not out: return - out = out.decode(sys.stdout.encoding) + out = out.decode(sys.getdefaultencoding()) if is_ws(out): return ous.write("### Parameters\n\n") diff --git a/scripts/mk_util.py b/scripts/mk_util.py index 635b8cec1e9..805aea19df3 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -122,7 +122,7 @@ def getenv(name, default): def check_output(cmd): out = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0] if out != None: - enc = sys.stdout.encoding + enc = sys.getdefaultencoding() if enc != None: return out.decode(enc).rstrip('\r\n') else: return out.rstrip('\r\n') else: diff --git a/scripts/update_api.py b/scripts/update_api.py index 62b961d67aa..a3d92a7e94b 100755 --- a/scripts/update_api.py +++ b/scripts/update_api.py @@ -1836,14 +1836,14 @@ def _to_pystr(s): else: def _str_to_bytes(s): if isinstance(s, str): - enc = sys.stdout.encoding + enc = sys.getdefaultencoding() return s.encode(enc if enc != None else 'latin-1') else: return s def _to_pystr(s): if s != None: - enc = sys.stdout.encoding + enc = sys.getdefaultencoding() return s.decode(enc if enc != None else 'latin-1') else: return ""