-
Notifications
You must be signed in to change notification settings - Fork 17
Frequently Encountered Bugs
Calum Freeman edited this page Aug 7, 2018
·
5 revisions
There are a number of bugs that can be accidentally written into code which will give obscure or difficult error messages. This guide aims to provide a useful list of the ones most frequently encountered. Some are obvious but it is worth checking just in case, it can save a lot of time debugging. They are grouped by which language's "fault" they are, not which language they occur in.
- When calling C from python:
function takes X args, (X given)
probably means you gave 1 too many arguments (I think self counts as an argument in the first number it gives but not the second) - Make sure to use
PyObject *
instead ofPyObject
- When parsing arguments from Python in C: make sure the format string is correct.
- When returning anything from C to Python you must use
Py_BuildValue()
- Java method not found error is often because the wrong types were given when declaring
JNI_METH_CLASS()
(Note: pyObject is not the type for pyString) - When using
(*env)->Call<type>Method()
, the<type>
must be the correct return type of the method(or field) - When calling
(*env)->Call<type>Method()
, the arguments passed must be of typej<type>
, this may involve converting a PyObject to a JythonPyObject or converting char* to jstring or converting PyString to char* to jstring
- Conflicting definitions for a function can mean it is used before being declared.
- Generally be careful with types, they are hard to check and: Jython String in C(jobject) != Python String in C(PyString) != C String(char*) != Java String(jstring)