Open chrispbradley opened 6 years ago
There should be a typemap that can be applied by SWIG saving the need for doing this directly. I would try the typemap first and then fall back to this.
Yes, I was going to change the typemap in https://github.com/OpenCMISS/iron/blob/develop/bindings/python/iron.i Is this what you mean?
The (python) bindings for the DiagnosticsSetOn routine is something like
iron.DiagnosticsSetOn(iron.DiagnosticTypes.FROM,[1,2,3,4,5],"Diagnostics",["routineName1","routineName2"])
with the last argument being a list of routine names. This worked for python 2 but it now doesn't work with python 3. The problem comes from the python wrapper code. The problem code in iron_python_wrapper.c is something like
Under python 3 the PyString_Check fails and so we get an "Expected a sequence of strings" error message.
In python 3 the strings are a bit different as the PyString calls no longer exist and are replaced with either PyByte or PyUnicode calls. SWIG tries to maintain python 2/3 compatibility by doing
/ Compatibility macros for Python 3 /
if PY_VERSION_HEX >= 0x03000000
...
define PyString_Check(name) PyBytes_Check(name)
...
However, what we really need is PyUnicode_Check as we are dealing with strings rather than raw bytes.
I suggest doing something like
if PY_VERSION_HEX >= 0x03000000
if(!PyUnicode_Check(o6) {
else
if(!PyString_Check(o6) {
endif
Any comments?