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 618669 - Handle callbacks as return types
Handle callbacks as return types
Status: RESOLVED FIXED
Product: pygi
Classification: Deprecated
Component: general
unspecified
Other Linux
: Normal normal
: 0.6
Assigned To: pygi-maint
pygi-maint
: 617804 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2010-05-14 19:16 UTC by johnp
Modified: 2010-05-20 17:10 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
[PATCH] support callbacks as return type (1.45 KB, patch)
2010-05-14 19:16 UTC, johnp
none Details | Review
[PATCH] don't error out on methods with callbacks as return type (1.16 KB, patch)
2010-05-19 20:38 UTC, johnp
accepted-commit_now Details | Review

Description johnp 2010-05-14 19:16:06 UTC
Right now we just throw an error when calling functions with a callback as a return type.  Usually the callback is returned so an app can clean up after another callback has replaced it.  

I'm not sure if we need this functionality or if we can even be sure to always get back a closure containing a python callback but this does make functions that return callbacks usable.

The correct patch might to be always return None.  The current patch is meant to jumpstart discussion on the correct way to handle callback returns.
Comment 1 johnp 2010-05-14 19:16:37 UTC
Created attachment 161092 [details] [review]
[PATCH] support callbacks as return type


* Right now we just throw an error which means API's like gtk_about_dialog_set_url_hook
  aren't able to be called, this allows us to call such APIs
* I'm not sure if this is the right patch - I'm thinking returning a callback is useless
  as we can't be 100% sure it is a Python callback wrapped in a closure.
* Also as the patch stands we will be returning None anyway since the callback is destroyed
  before the return arg is processed
* It might be best to just return None but for now I present this patch so we can figure
  out how we want to handle callback returns
---
 gi/pygi-argument.c |   23 +++++++++++++++++++++--
 1 files changed, 21 insertions(+), 2 deletions(-)
Comment 2 johnp 2010-05-17 15:02:58 UTC
*** Bug 617804 has been marked as a duplicate of this bug. ***
Comment 3 johnp 2010-05-19 20:38:02 UTC
Created attachment 161491 [details] [review]
[PATCH] don't error out on methods with callbacks as return type


* Right now we just throw an error which means API's like
  gtk_about_dialog_set_url_hook aren't able to be called,
* this allows us to call such APIs while printing a warning, in most cases
  API such as this doesn't need to be used anymore and is a result of
  early GTK development
---
 gi/pygi-argument.c |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)
Comment 4 johnp 2010-05-19 20:39:01 UTC
Decided the only sane thing to do is print an error and return None
Comment 5 johnp 2010-05-19 20:39:24 UTC
I meant print a warning and return None
Comment 6 Tomeu Vizoso 2010-05-20 08:11:03 UTC
Review of attachment 161491 [details] [review]:

Please replace tabs with spaces before pushing.
Comment 7 johnp 2010-05-20 17:10:02 UTC
Committed with tab fixes