On Mon, 2011-12-05 at 21:05 +0100, Frederik Elwert wrote: > Am Montag, den 05.12.2011, 19:17 +0000 schrieb Philip Withnall: > > On Mon, 2011-12-05 at 19:15 +0100, Frederik Elwert wrote: > > > > Le vendredi 02 décembre 2011 à 10:21 +0100, Frederik Elwert a écrit : > > > > > Now since we would prefer using python for our application, I was > > > > > wondering if it is possible to access Folks from python. I could > > > > > manage > > > > > to import it from gi.repository, but it then fails during > > > > > IndividualAggregator.prepare(): > > > > > > > > > > from gi.repository import Folks > > > > > agg = Folks.IndividualAggregator() > > > > > agg.prepare() > > > > > Traceback (most recent call last): > > > > > File "<stdin>", line 1, in <module> > > > > > File "/usr/lib/python2.7/dist-packages/gi/types.py", line > > > > > 43, > > > > > in function > > > > > return info.invoke(*args, **kwargs) > > > > > TypeError: prepare() takes exactly 3 arguments (1 given) > > > > > > > > > > I have seen that the generated c code has this function signature: > > > > > > > > > > void folks_individual_aggregator_prepare > > > > > (FolksIndividualAggregator* self, GAsyncReadyCallback > > > > > _callback_, gpointer _user_data_); > > > > > > > > I don't think you can omit arguments with g-i/pygobject. The only > > > > annotation that we can set is (allow-none) but even then you have to > > > > pass 'None' to it. > > > > > > > > agg.prepare(None, None) should work. otoh, you probably want to set a > > > > callback to know when you can start using that aggregator... > > > > > > It somehow seems to do something, but then segfaults: > > > > > > agg.prepare(None, None) > > > (process:5627): folks-DEBUG: Using built-in backends key file > > > '/home/frederik/.local/share/folks/backends.ini' (override with > > > environment variable FOLKS_BACKEND_STORE_KEY_FILE_PATH) > > > Speicherzugriffsfehler [segmentation fault in German] > > > > > > I also get a segfault when passing a python function as callback. > > > > Please provide a stacktrace (either here or as a bug against folks on > > bugzilla.gnome.org) and we can take a look. > > I attached a python test file and the gdb output. (I’m not too familiar > with debugging, so if you need additional information, please let me > know.)
The stacktrace wasn't too useful without libfolks debug symbols, but I could reproduce the problem myself with the program you provided. This looks like a bug in the way folks handles construction of IndividualAggregators which doesn't show up when folks is used from C or Vala, but is quite obvious when folks is used from Python. I've opened https://bugzilla.gnome.org/show_bug.cgi?id=665692 about it, and I'm working on a patch now. I've CCed you to the bug (I hope you don't mind). Philip > > > It might be because I’m rather new to GI, but I am a bit confused by the > > > API difference between C (prepare taking parameters) and Vala (prepare > > > as instance method taking no parameters). First, I looked at the Vala > > > API and assumed that Python would have a similar one. > > > > The prepare() method is async (using GAsyncResult). It takes parameters > > in C because that's the only way async methods can be implemented in C. > > In Vala, however, the ‘async’ keyword is used instead. Since async > > methods aren't supported in Python it uses the same parameters as the C > > code. > > Okay, I see. Thanks for the explanation. > > Regards > Frederik > _______________________________________________ > telepathy mailing list > [email protected] > http://lists.freedesktop.org/mailman/listinfo/telepathy
signature.asc
Description: This is a digitally signed message part
_______________________________________________ telepathy mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/telepathy
