Allow to pass None for array (example: String[] can be null.)

This commit is contained in:
Mathieu Virbel 2013-06-23 15:46:25 +02:00
parent bd3f007ed3
commit 3fe55c1bb2
1 changed files with 9 additions and 7 deletions

View File

@ -74,11 +74,13 @@ cdef void populate_args(JNIEnv *j_env, tuple definition_args, jvalue *j_args, ar
'argument. Want {0!r}, got {1!r}'.format( 'argument. Want {0!r}, got {1!r}'.format(
argtype[1:-1], py_arg)) argtype[1:-1], py_arg))
elif argtype[0] == '[': elif argtype[0] == '[':
if py_arg is None:
j_args[index].l = NULL
else:
if not isinstance(py_arg, list) and \ if not isinstance(py_arg, list) and \
not isinstance(py_arg, tuple): not isinstance(py_arg, tuple):
raise JavaException('Expecting a python list/tuple, got ' raise JavaException('Expecting a python list/tuple, got '
'{0!r}'.format(py_arg)) '{0!r}'.format(py_arg))
j_args[index].l = convert_pyarray_to_java( j_args[index].l = convert_pyarray_to_java(
j_env, argtype[1:], py_arg) j_env, argtype[1:], py_arg)