From 01c259029882334216b7ffe8d99ed1f35cd8e462 Mon Sep 17 00:00:00 2001 From: Peter Badida Date: Wed, 2 Jan 2019 22:47:35 +0100 Subject: [PATCH] Handle case when passing an empty Python tuple/list to Java function as argument --- jnius/jnius_conversion.pxi | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/jnius/jnius_conversion.pxi b/jnius/jnius_conversion.pxi index 8a2aba0..f155c6e 100644 --- a/jnius/jnius_conversion.pxi +++ b/jnius/jnius_conversion.pxi @@ -485,6 +485,7 @@ cdef jstring convert_pystr_to_java(JNIEnv *j_env, basestring py_str) except NULL cdef jobject convert_pyarray_to_java(JNIEnv *j_env, definition, pyarray) except *: cdef jobject ret = NULL + cdef jobject nested = NULL cdef int array_size = len(pyarray) cdef int i cdef unsigned char c_tmp @@ -622,6 +623,17 @@ cdef jobject convert_pyarray_to_java(JNIEnv *j_env, definition, pyarray) except ) j_env[0].DeleteLocalRef(j_env, j_string) + # isinstance(arg, type) will return False + # ...and it's really weird + elif isinstance(arg, (tuple, list)): + nested = convert_pyarray_to_java( + j_env, definition, arg + ) + j_env[0].SetObjectArrayElement( + j_env, ret, i, nested + ) + j_env[0].DeleteLocalRef(j_env, nested) + # no local refs to delete for class, type and object elif isinstance(arg, JavaClass): jc = arg