After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 619235 - [PATCH] Fix up nullable array tests along with an array argument crasher bug
[PATCH] Fix up nullable array tests along with an array argument crasher bug
Status: RESOLVED FIXED
Product: pygi
Classification: Deprecated
Component: general
unspecified
Other Linux
: Normal normal
: 0.6
Assigned To: pygi-maint
pygi-maint
Depends on:
Blocks:
 
 
Reported: 2010-05-20 21:19 UTC by johnp
Modified: 2010-05-22 11:14 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
[PATCH] fix NULL array unit tests and fix crasher when sending None as an array (1.69 KB, patch)
2010-05-20 21:19 UTC, johnp
committed Details | Review
fix NULL array unit tests and fix crasher when sending None as an array (2.84 KB, patch)
2010-05-22 11:14 UTC, Tomeu Vizoso
committed Details | Review

Description johnp 2010-05-20 21:19:13 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.
Comment 1 johnp 2010-05-20 21:19:43 UTC
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(-)
Comment 2 Tomeu Vizoso 2010-05-22 11:09:05 UTC
Review of attachment 161594 [details] [review]:

Good catch, thanks!
Comment 3 Tomeu Vizoso 2010-05-22 11:14:49 UTC
The following fix has been pushed:
ab1aaff fix NULL array unit tests and fix crasher when sending None as an array
Comment 4 Tomeu Vizoso 2010-05-22 11:14:55 UTC
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.