Using Z3Py With Python 3.3

筅森魡賤 提交于 2019-12-20 04:11:47

问题


My Situation

I've installed Microsoft Z3 (Z3 [version 4.3.0 - 64 bit]. (C) 2006) and it's pyc binaries for Python2.

I've written an Python3 package which needs access to z3 functionality.

In order to be able to use the pyc binaries with my Python3 package, I decompyle the z3 binaries and applied 2to3.

My Problem

Int('string') doesn't work because Z3Py isn't able to handle the new <class 'str'> used as 'string' argument:

>>> import z3; z3.Int('abc')

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".\bin\z3.py", line 2931, in Int
    return ArithRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), IntSort(ctx).ast), ctx)
  File ".\bin\z3.py", line 72, in to_symbol
    return Z3_mk_string_symbol(_get_ctx(ctx).ref(), s)
  File ".\bin\z3core.py", line 1430, in Z3_mk_string_symbol
    r = lib().Z3_mk_string_symbol(a0, a1)
ctypes.ArgumentError: argument 2: <class 'TypeError'>: wrong type

My Questions

  • It's a little bit hacky to need to decompyle Z3's *.pyc files first. So, are there any Z3Py source codes available?
  • Is there already an existing Z3Py port to Python3?
  • Any other idea how to get Z3Py to run with Python3?

Thanks. - If anything's unclear, please leave a question comment.


回答1:


The unstable (work-in-progress) has support for Python 3. This feature will be available in the next Z3 release (v4.3.2). In the meantime, you can build the unstable branch using the instructions found here.



来源:https://stackoverflow.com/questions/15598669/using-z3py-with-python-3-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!