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.)

> > 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
#!/usr/bin/env python

from gi.repository import Folks


def callback(source, result, user_data=None):
    pass

agg = Folks.IndividualAggregator()
agg.prepare(callback, None)
$ gdb python
GNU gdb (Ubuntu/Linaro 7.3-0ubuntu2) 7.3-2011.08
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-linux-gnu".
For bug reporting instructions, please see:
<http://bugs.launchpad.net/gdb-linaro/>...
Reading symbols from /usr/bin/python...Reading symbols from /usr/lib/debug/usr/bin/python2.7...done.
done.
(gdb) run folkstest.py
Starting program: /usr/bin/python folkstest.py
[Thread debugging using libthread_db enabled]
(process:7901): 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)

Program received signal SIGSEGV, Segmentation fault.
0x008d63d2 in ?? () from /usr/lib/libfolks.so.25
(gdb) bt
#0  0x008d63d2 in ?? () from /usr/lib/libfolks.so.25
#1  0x008d7c47 in ?? () from /usr/lib/libfolks.so.25
#2  0x008d8127 in ?? () from /usr/lib/libfolks.so.25
#3  0x008f2a17 in ?? () from /usr/lib/libfolks.so.25
#4  0x007f335a in ffi_call_SYSV () from /usr/lib/i386-linux-gnu/libffi.so.6
#5  0x007f308f in ffi_call () from /usr/lib/i386-linux-gnu/libffi.so.6
#6  0x0052919b in ?? () from /usr/lib/libgirepository-1.0.so.1
#7  0x0052a6f1 in g_function_info_invoke ()
   from /usr/lib/libgirepository-1.0.so.1
#8  0x00511b57 in ?? () from /usr/lib/python2.7/dist-packages/gi/_gi.so
#9  0x080fade1 in ext_do_call (nk=0, na=137154640, flags=<optimized out>, 
    pp_stack=0xbfffeea4, func=
    <built-in method invoke of gi.FunctionInfo object at remote 0xb7b950cc>)
    at ../Python/ceval.c:4331
#10 PyEval_EvalFrameEx (f=
    Frame 0x83d2a8c, for file /usr/lib/python2.7/dist-packages/gi/types.py, line 43, in function (args=(<IndividualAggregator at remote 0xb7b9293c>, <function at remote 0xb7b8f4c4>, None), kwargs={}), throwflag=0) at ../Python/ceval.c:2705
#11 0x080fdcd1 in PyEval_EvalCodeEx (co=0xb7b866e0, globals=
    {'StructMeta': <type at remote 0x83bf0ec>, 'absolute_import': <_Feature(mandatory=(2, 7, 0, 'alpha', 0), optional=(2, 5, 0, 'alpha', 1), compiler_flag=16384) at remote 0xb7f42e8c>, 'register_interface_info': <built-in function register_interface_info>, 'ObjectInfo': <type at remote 0x51fca0>, 'Function': <function ---Type <return> to continue, or q <return> to quit---
at remote 0xb7b8f79c>, '__package__': 'gi', 'MetaClassHelper': <type at remote 0x83c3c34>, '_gobject': <module at remote 0xb7f37a94>, '__doc__': None, 'hook_up_vfunc_implementation': <built-in function hook_up_vfunc_implementation>, '__builtins__': {'bytearray': <type at remote 0x826d180>, 'IndexError': <type at remote 0x8272a40>, 'all': <built-in function all>, 'help': <_Helper at remote 0xb7f28ccc>, 'vars': <built-in function vars>, 'SyntaxError': <type at remote 0x82726c0>, 'unicode': <type at remote 0x82804a0>, 'UnicodeDecodeError': <type at remote 0x8272ea0>, 'memoryview': <type at remote 0x8279ee0>, 'isinstance': <built-in function isinstance>, 'copyright': <_Printer(_Printer__data='Copyright ...(truncated), locals=0x0, args=0x8319c04, argcount=3, kws=0x8319c10, kwcount=0, defs=
    0x0, defcount=0, closure=(<cell at remote 0xb7beda34>,))
    at ../Python/ceval.c:3253
#12 0x080f7cdf in fast_function (nk=<optimized out>, na=3, n=<optimized out>, 
    pp_stack=0xbfffeff4, func=<function at remote 0xb7b8fe64>)
    at ../Python/ceval.c:4117
#13 call_function (oparg=2, pp_stack=0xbfffeff4) at ../Python/ceval.c:4042
#14 PyEval_EvalFrameEx (f=
    Frame 0x8319acc, for file folkstest.py, line 10, in <module> (), 
    throwflag=0) at ../Python/ceval.c:2666
#15 0x080fd804 in PyEval_EvalCodeEx (co=0xb7f9fbf0, globals=
    {'__builtins__': <module at remote 0xb7fa511c>, '__file__': 'folkstest.py', '__package__': None, 'callback': <function at remote 0xb7b8f4c4>, 'agg': <IndividualAggregator at remote 0xb7b9293c>, 'Folks': <DynamicModule(_overrides_module=---Type <return> to continue, or q <return> to quit---
None, _namespace='Folks', _introspection_module=<IntrospectionModule(__name__='gi.repository.Folks', _namespace='Folks', _version='0.6', IndividualAggregator=<GObjectMeta(unlink_individual=<function at remote 0xb7b9617c>, __module__='gi.repository.Folks', remove_persona_finish=<function at remote 0xb7b960d4>, link_personas=<function at remote 0xb7b9610c>, ensure_individual_property_writeable_finish=<function at remote 0xb7b96224>, prepare_finish=<function at remote 0xb7b8fe2c>, __info__=<ObjectInfo at remote 0xb7b91e0c>, priv=<property at remote 0xb7b92914>, parent_instance=<property at remote 0xb7b928ec>, link_personas_finish=<function at remote 0xb7b96144>, get_all_potential_matches=<function at remote 0xb7b8fed4>, prepare=<function at remote 0xb7b8fe64>, new=<classmethod at ...(truncated), locals=
    {'__builtins__': <module at remote 0xb7fa511c>, '__file__': 'folkstest.py', '__package__': None, 'callback': <function at remote 0xb7b8f4c4>, 'agg': <IndividualAggregator at remote 0xb7b9293c>, 'Folks': <DynamicModule(_overrides_module=None, _namespace='Folks', _introspection_module=<IntrospectionModule(__name__='gi.repository.Folks', _namespace='Folks', _version='0.6', IndividualAggregator=<GObjectMeta(unlink_individual=<function at remote 0xb7b9617c>, __module__='gi.repository.Folks', remove_persona_finish=<function at remote 0xb7b960d4>, link_personas=<function at remote 0xb7b9610c>, ensure_individual_property_writeable_finish=<function at remote 0xb7b96224>, prepare_finish=<function at remote 0xb7b8fe2c>, __info__=<ObjectInfo at remote 0xb7b91e0c>, priv=<property at remote 0xb7b92914>, parent_instance=<property at remote 0xb7b928ec>, link_personas_finish=<function at remote 0xb7b96144>, get_all_potential_matches=<function at remote 0xb7b8---Type <return> to continue, or q <return> to quit---
fed4>, prepare=<function at remote 0xb7b8fe64>, new=<classmethod at ...(truncated), args=0x0, argcount=0, kws=0x0, kwcount=0, defs=0x0, defcount=0, closure=
    0x0) at ../Python/ceval.c:3253
#16 0x080fe177 in PyEval_EvalCode (co=0xb7f9fbf0, globals=
    {'__builtins__': <module at remote 0xb7fa511c>, '__file__': 'folkstest.py', '__package__': None, 'callback': <function at remote 0xb7b8f4c4>, 'agg': <IndividualAggregator at remote 0xb7b9293c>, 'Folks': <DynamicModule(_overrides_module=None, _namespace='Folks', _introspection_module=<IntrospectionModule(__name__='gi.repository.Folks', _namespace='Folks', _version='0.6', IndividualAggregator=<GObjectMeta(unlink_individual=<function at remote 0xb7b9617c>, __module__='gi.repository.Folks', remove_persona_finish=<function at remote 0xb7b960d4>, link_personas=<function at remote 0xb7b9610c>, ensure_individual_property_writeable_finish=<function at remote 0xb7b96224>, prepare_finish=<function at remote 0xb7b8fe2c>, __info__=<ObjectInfo at remote 0xb7b91e0c>, priv=<property at remote 0xb7b92914>, parent_instance=<property at remote 0xb7b928ec>, link_personas_finish=<function at remote 0xb7b96144>, get_all_potential_matches=<function at remote 0xb7b8fed4>, prepare=<function at remote 0xb7b8fe64>, new=<classmethod at ...(truncated), locals=
    {'__builtins__': <module at remote 0xb7fa511c>, '__file__': 'folkstest.py', '__package__': None, 'callback': <function at remote 0xb7b8f4c4>, 'agg': <IndividualAggregator at remote 0xb7b9293c>, 'Folks': <DynamicModule(_overrides_module=None, _namespace='Folks', _introspection_module=<IntrospectionModule(__name__='gi.repository.Folks', _namespace='Folks', _version='0.6', IndividualAggregator=<G---Type <return> to continue, or q <return> to quit---
ObjectMeta(unlink_individual=<function at remote 0xb7b9617c>, __module__='gi.repository.Folks', remove_persona_finish=<function at remote 0xb7b960d4>, link_personas=<function at remote 0xb7b9610c>, ensure_individual_property_writeable_finish=<function at remote 0xb7b96224>, prepare_finish=<function at remote 0xb7b8fe2c>, __info__=<ObjectInfo at remote 0xb7b91e0c>, priv=<property at remote 0xb7b92914>, parent_instance=<property at remote 0xb7b928ec>, link_personas_finish=<function at remote 0xb7b96144>, get_all_potential_matches=<function at remote 0xb7b8fed4>, prepare=<function at remote 0xb7b8fe64>, new=<classmethod at ...(truncated)) at ../Python/ceval.c:667
#17 0x0811acd0 in run_mod (mod=<optimized out>, filename=<optimized out>, 
    globals=
    {'__builtins__': <module at remote 0xb7fa511c>, '__file__': 'folkstest.py', '__package__': None, 'callback': <function at remote 0xb7b8f4c4>, 'agg': <IndividualAggregator at remote 0xb7b9293c>, 'Folks': <DynamicModule(_overrides_module=None, _namespace='Folks', _introspection_module=<IntrospectionModule(__name__='gi.repository.Folks', _namespace='Folks', _version='0.6', IndividualAggregator=<GObjectMeta(unlink_individual=<function at remote 0xb7b9617c>, __module__='gi.repository.Folks', remove_persona_finish=<function at remote 0xb7b960d4>, link_personas=<function at remote 0xb7b9610c>, ensure_individual_property_writeable_finish=<function at remote 0xb7b96224>, prepare_finish=<function at remote 0xb7b8fe2c>, __info__=<ObjectInfo at remote 0xb7b91e0c>, priv=<property at remote 0xb7b92914>, parent_instance=<property at remote 0xb7b928ec>, link_personas_finish=<function at remote 0xb7b96144>, get_all_potential_matches=<function at remote 0xb7b8---Type <return> to continue, or q <return> to quit---
fed4>, prepare=<function at remote 0xb7b8fe64>, new=<classmethod at ...(truncated), locals=
    {'__builtins__': <module at remote 0xb7fa511c>, '__file__': 'folkstest.py', '__package__': None, 'callback': <function at remote 0xb7b8f4c4>, 'agg': <IndividualAggregator at remote 0xb7b9293c>, 'Folks': <DynamicModule(_overrides_module=None, _namespace='Folks', _introspection_module=<IntrospectionModule(__name__='gi.repository.Folks', _namespace='Folks', _version='0.6', IndividualAggregator=<GObjectMeta(unlink_individual=<function at remote 0xb7b9617c>, __module__='gi.repository.Folks', remove_persona_finish=<function at remote 0xb7b960d4>, link_personas=<function at remote 0xb7b9610c>, ensure_individual_property_writeable_finish=<function at remote 0xb7b96224>, prepare_finish=<function at remote 0xb7b8fe2c>, __info__=<ObjectInfo at remote 0xb7b91e0c>, priv=<property at remote 0xb7b92914>, parent_instance=<property at remote 0xb7b928ec>, link_personas_finish=<function at remote 0xb7b96144>, get_all_potential_matches=<function at remote 0xb7b8fed4>, prepare=<function at remote 0xb7b8fe64>, new=<classmethod at ...(truncated), flags=0xbffff26c, arena=0x82ece28) at ../Python/pythonrun.c:1346
#18 0x0811b8e9 in PyRun_FileExFlags (fp=0x83369a0, filename=
    0xbffff4d8 "folkstest.py", start=257, globals=
    {'__builtins__': <module at remote 0xb7fa511c>, '__file__': 'folkstest.py', '__package__': None, 'callback': <function at remote 0xb7b8f4c4>, 'agg': <IndividualAggregator at remote 0xb7b9293c>, 'Folks': <DynamicModule(_overrides_module=None, _namespace='Folks', _introspection_module=<IntrospectionModule(__name__='gi.repository.Folks', _namespace='Folks', _version='0.6', IndividualAggregator=<G---Type <return> to continue, or q <return> to quit---
ObjectMeta(unlink_individual=<function at remote 0xb7b9617c>, __module__='gi.repository.Folks', remove_persona_finish=<function at remote 0xb7b960d4>, link_personas=<function at remote 0xb7b9610c>, ensure_individual_property_writeable_finish=<function at remote 0xb7b96224>, prepare_finish=<function at remote 0xb7b8fe2c>, __info__=<ObjectInfo at remote 0xb7b91e0c>, priv=<property at remote 0xb7b92914>, parent_instance=<property at remote 0xb7b928ec>, link_personas_finish=<function at remote 0xb7b96144>, get_all_potential_matches=<function at remote 0xb7b8fed4>, prepare=<function at remote 0xb7b8fe64>, new=<classmethod at ...(truncated), locals=
    {'__builtins__': <module at remote 0xb7fa511c>, '__file__': 'folkstest.py', '__package__': None, 'callback': <function at remote 0xb7b8f4c4>, 'agg': <IndividualAggregator at remote 0xb7b9293c>, 'Folks': <DynamicModule(_overrides_module=None, _namespace='Folks', _introspection_module=<IntrospectionModule(__name__='gi.repository.Folks', _namespace='Folks', _version='0.6', IndividualAggregator=<GObjectMeta(unlink_individual=<function at remote 0xb7b9617c>, __module__='gi.repository.Folks', remove_persona_finish=<function at remote 0xb7b960d4>, link_personas=<function at remote 0xb7b9610c>, ensure_individual_property_writeable_finish=<function at remote 0xb7b96224>, prepare_finish=<function at remote 0xb7b8fe2c>, __info__=<ObjectInfo at remote 0xb7b91e0c>, priv=<property at remote 0xb7b92914>, parent_instance=<property at remote 0xb7b928ec>, link_personas_finish=<function at remote 0xb7b96144>, get_all_potential_matches=<function at remote 0xb7b8fed4>, prepare=<function at remote 0xb7b8fe64>, new=<classmethod at ...(truncated), closeit=1, flags=0xbffff26c) at ../Python/pythonrun.c:1332
---Type <return> to continue, or q <return> to quit---
#19 0x0811c4cc in PyRun_SimpleFileExFlags (fp=0x83369a0, 
    filename=<optimized out>, closeit=1, flags=0xbffff26c)
    at ../Python/pythonrun.c:936
#20 0x0812c7c6 in Py_Main (argc=2, argv=0xbffff344) at ../Modules/main.c:599
#21 0x0805da0b in main (argc=2, argv=0xbffff344) at ../Modules/python.c:23
_______________________________________________
telepathy mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/telepathy

Reply via email to