Merge "Omaha #4259 fix when java method expects string arg and gets java.lang.String instead of Py_String" into omaha_16.1.1
Former-commit-id: 842dfb0fa6e7a3cda122f14148a18b5cb83b5eee
This commit is contained in:
commit
418d41e200
1 changed files with 16 additions and 2 deletions
|
@ -1565,9 +1565,23 @@ jvalue convert_pyarg_jvalue(JNIEnv *env,
|
||||||
char *val;
|
char *val;
|
||||||
|
|
||||||
// none is okay, we'll set a null
|
// none is okay, we'll set a null
|
||||||
if(param == Py_None)
|
if(param == Py_None) {
|
||||||
ret.l = NULL;
|
ret.l = NULL;
|
||||||
else {
|
} else if(pyjobject_check(param)) {
|
||||||
|
// if they pass in a pyjobject with java.lang.String inside it
|
||||||
|
jclass strClazz;
|
||||||
|
PyJobject_Object *obj = (PyJobject_Object*) param;
|
||||||
|
strClazz = (*env)->FindClass(env, "java/lang/String");
|
||||||
|
if(!(*env)->IsInstanceOf(env, obj->object, strClazz)) {
|
||||||
|
PyErr_Format(PyExc_TypeError,
|
||||||
|
"Expected string parameter at %i.",
|
||||||
|
pos + 1);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret.l = obj->object;
|
||||||
|
return ret;
|
||||||
|
} else {
|
||||||
// we could just convert it to a string...
|
// we could just convert it to a string...
|
||||||
if(!PyString_Check(param)) {
|
if(!PyString_Check(param)) {
|
||||||
PyErr_Format(PyExc_TypeError,
|
PyErr_Format(PyExc_TypeError,
|
||||||
|
|
Loading…
Add table
Reference in a new issue