3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-06-09 15:43:25 +00:00
This commit is contained in:
pcarbonn 2021-01-22 07:16:49 +01:00 committed by GitHub
parent 4e8ba8b160
commit 0eb04df834
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1819,25 +1819,33 @@ if _lib is None:
print(" builtins.Z3_LIB_DIRS = [ '/path/to/libz3.%s' ] " % _ext) print(" builtins.Z3_LIB_DIRS = [ '/path/to/libz3.%s' ] " % _ext)
raise Z3Exception("libz3.%s not found." % _ext) raise Z3Exception("libz3.%s not found." % _ext)
def _str_to_bytes(s): # def _str_to_bytes(s):
if isinstance(s, str): # if isinstance(s, str):
try: # try:
return s.encode('latin-1') # return s.encode('latin-1')
except: # except:
# kick the bucket down the road. :-J # # kick the bucket down the road. :-J
return s # return s
else: # else:
return s # return s
if sys.version < '3': if sys.version < '3':
def _str_to_bytes(s):
return s
def _to_pystr(s): def _to_pystr(s):
return s return s
else: else:
def _str_to_bytes(s):
if isinstance(s, str):
enc = sys.stdout.encoding
return s.encode(enc if enc != None else 'latin-1')
else:
return s
def _to_pystr(s): def _to_pystr(s):
if s != None: if s != None:
enc = sys.stdout.encoding enc = sys.stdout.encoding
if enc != None: return s.decode(enc) return s.decode(enc if enc != None else 'latin-1')
else: return s.decode('latin-1')
else: else:
return "" return ""