GNOME Bugzilla – Bug 619235
[PATCH] Fix up nullable array tests along with an array argument crasher bug
Last modified: 2010-05-22 11:14:55 UTC
Tests weren't constant with the actual interface as annotated. They were sending in or expecting a length argument to be returned which for arrays is encapsulated inside the returned type. This revealed a crasher bug when sending None in place of an array (e.g. a NULL array). This patch also fixes that.
Created attachment 161594 [details] [review] [PATCH] fix NULL array unit tests and fix crasher when sending None as an array * Unit tests were wrong given the annotation for test_array_int_null_in and test_array_int_null_out: /** * test_array_int_null_in: * @arr: (array length=len) (allow-none): * @len: length */ -- and -- /** * test_array_int_null_out: * @arr: (out) (array length=len) (allow-none): * @len: (out) : length */ The (array length=len) annotation meant we don't pass in or receive the len argument as this is handled under the hood (Python's representation of an array, the list type, encapsulates the length inside the type) * Fixing up the tests revealed a latent crasher bug when passing None to an interface that accepts an array. The fix was to check for NULL and set the length argument to 0 when invoking the bound method. --- gi/pygi-invoke.c | 6 +++++- tests/test_everything.py | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-)
Review of attachment 161594 [details] [review]: Good catch, thanks!
The following fix has been pushed: ab1aaff fix NULL array unit tests and fix crasher when sending None as an array
Created attachment 161715 [details] [review] fix NULL array unit tests and fix crasher when sending None as an array * Unit tests were wrong given the annotation for test_array_int_null_in and test_array_int_null_out: /** * test_array_int_null_in: * @arr: (array length=len) (allow-none): * @len: length */ -- and -- /** * test_array_int_null_out: * @arr: (out) (array length=len) (allow-none): * @len: (out) : length */ The (array length=len) annotation meant we don't pass in or receive the len argument as this is handled under the hood (Python's representation of an array, the list type, encapsulates the length inside the type) * Fixing up the tests revealed a latent crasher bug when passing None to an interface that accepts an array. The fix was to check for NULL and set the length argument to 0 when invoking the bound method.