From 3fe55c1bb292c1ae381a3120de9b36c8afc6e859 Mon Sep 17 00:00:00 2001 From: Mathieu Virbel Date: Sun, 23 Jun 2013 15:46:25 +0200 Subject: [PATCH] Allow to pass None for array (example: String[] can be null.) --- jnius/jnius_conversion.pxi | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/jnius/jnius_conversion.pxi b/jnius/jnius_conversion.pxi index 17e05c0..3e966d4 100644 --- a/jnius/jnius_conversion.pxi +++ b/jnius/jnius_conversion.pxi @@ -74,13 +74,15 @@ cdef void populate_args(JNIEnv *j_env, tuple definition_args, jvalue *j_args, ar 'argument. Want {0!r}, got {1!r}'.format( argtype[1:-1], py_arg)) elif argtype[0] == '[': - if not isinstance(py_arg, list) and \ - not isinstance(py_arg, tuple): - raise JavaException('Expecting a python list/tuple, got ' - '{0!r}'.format(py_arg)) - - j_args[index].l = convert_pyarray_to_java( - j_env, argtype[1:], py_arg) + if py_arg is None: + j_args[index].l = NULL + else: + if not isinstance(py_arg, list) and \ + not isinstance(py_arg, tuple): + raise JavaException('Expecting a python list/tuple, got ' + '{0!r}'.format(py_arg)) + j_args[index].l = convert_pyarray_to_java( + j_env, argtype[1:], py_arg) cdef convert_jobject_to_python(JNIEnv *j_env, bytes definition, jobject j_object):