mirror of
https://github.com/Z3Prover/z3
synced 2025-04-13 04:28:17 +00:00
Fixed error handlers in Python API.
This commit is contained in:
parent
bec6c3f9e2
commit
17bcb37cf1
|
@ -330,8 +330,10 @@ class Elementaries:
|
|||
raise self.Exception(self.get_error_message(ctx, err))
|
||||
|
||||
def Z3_set_error_handler(ctx, hndlr, _elems=Elementaries(_lib.Z3_set_error_handler)):
|
||||
_elems.f(ctx, ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_uint)(hndlr))
|
||||
ceh = _error_handler_type(hndlr)
|
||||
_elems.f(ctx, ceh)
|
||||
_elems.Check(ctx)
|
||||
return ceh
|
||||
|
||||
""")
|
||||
|
||||
|
@ -1710,8 +1712,10 @@ else:
|
|||
else:
|
||||
return ""
|
||||
|
||||
_error_handler_type = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_uint)
|
||||
|
||||
_lib.Z3_set_error_handler.restype = None
|
||||
_lib.Z3_set_error_handler.argtypes = [ContextObj, ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_uint)]
|
||||
_lib.Z3_set_error_handler.argtypes = [ContextObj, _error_handler_type]
|
||||
|
||||
"""
|
||||
)
|
||||
|
|
|
@ -125,11 +125,6 @@ def _get_args(args):
|
|||
except: # len is not necessarily defined when args is not a sequence (use reflection?)
|
||||
return args
|
||||
|
||||
def z3_error_handler(c, e):
|
||||
# Do nothing error handler, just avoid exit(0)
|
||||
# The wrappers in z3core.py will raise a Z3Exception if an error is detected
|
||||
return
|
||||
|
||||
def _to_param_value(val):
|
||||
if isinstance(val, bool):
|
||||
if val == True:
|
||||
|
@ -139,6 +134,11 @@ def _to_param_value(val):
|
|||
else:
|
||||
return str(val)
|
||||
|
||||
def z3_error_handler(c, e):
|
||||
# Do nothing error handler, just avoid exit(0)
|
||||
# The wrappers in z3core.py will raise a Z3Exception if an error is detected
|
||||
return
|
||||
|
||||
class Context:
|
||||
"""A Context manages all other Z3 objects, global configuration options, etc.
|
||||
|
||||
|
@ -165,13 +165,14 @@ class Context:
|
|||
Z3_set_param_value(conf, str(prev), _to_param_value(a))
|
||||
prev = None
|
||||
self.ctx = Z3_mk_context_rc(conf)
|
||||
self.eh = Z3_set_error_handler(self.ctx, z3_error_handler)
|
||||
Z3_set_ast_print_mode(self.ctx, Z3_PRINT_SMTLIB2_COMPLIANT)
|
||||
Z3_set_error_handler(self.ctx, z3_error_handler)
|
||||
Z3_del_config(conf)
|
||||
|
||||
def __del__(self):
|
||||
Z3_del_context(self.ctx)
|
||||
self.ctx = None
|
||||
self.eh = None
|
||||
|
||||
def ref(self):
|
||||
"""Return a reference to the actual C pointer to the Z3 context."""
|
||||
|
|
Loading…
Reference in a new issue