mirror of
https://github.com/Z3Prover/z3
synced 2025-04-23 00:55:31 +00:00
Use the latin-1 codec instead of ascii in Python bindings.
The latin-1 codec maps byte values 0-255 to unicode codepoints 0-255. The ascii codec only maps the lower half of that range.
This commit is contained in:
parent
bba2cf9f20
commit
a20d4fa362
2 changed files with 5 additions and 5 deletions
|
@ -308,7 +308,7 @@ def display_args_to_z3(params):
|
|||
if i > 0:
|
||||
core_py.write(", ")
|
||||
if param_type(p) == STRING:
|
||||
core_py.write("_to_ascii(a%s)" % i)
|
||||
core_py.write("_str_to_bytes(a%s)" % i)
|
||||
else:
|
||||
core_py.write("a%s" % i)
|
||||
i = i + 1
|
||||
|
@ -1790,10 +1790,10 @@ if _lib is None:
|
|||
print(" builtins.Z3_LIB_DIRS = [ '/path/to/libz3.%s' ] " % _ext)
|
||||
raise Z3Exception("libz3.%s not found." % _ext)
|
||||
|
||||
def _to_ascii(s):
|
||||
def _str_to_bytes(s):
|
||||
if isinstance(s, str):
|
||||
try:
|
||||
return s.encode('ascii')
|
||||
return s.encode('latin-1')
|
||||
except:
|
||||
# kick the bucket down the road. :-J
|
||||
return s
|
||||
|
@ -1808,7 +1808,7 @@ else:
|
|||
if s != None:
|
||||
enc = sys.stdout.encoding
|
||||
if enc != None: return s.decode(enc)
|
||||
else: return s.decode('ascii')
|
||||
else: return s.decode('latin-1')
|
||||
else:
|
||||
return ""
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue