Skip to content

Commit

Permalink
Use sys.getdefaultencoding() instead of sys.stdout.encoding (#6612)
Browse files Browse the repository at this point in the history
  • Loading branch information
twizmwazin authored Feb 28, 2023
1 parent 6e7d806 commit 1a9990a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions doc/mk_params_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion doc/mk_tactic_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion scripts/mk_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions scripts/update_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
Expand Down

0 comments on commit 1a9990a

Please sign in to comment.