[Telepathy] Accessing Folks from python, part 2

Frederik Elwert frederik.elwert at web.de
Mon Jan 23 07:21:30 PST 2012


Am Montag, den 23.01.2012, 14:40 +0000 schrieb Philip Withnall:
> On Mon, 2012-01-23 at 10:22 +0100, Frederik Elwert wrote:
> > Hello,
> > 
> > I am still trying to write a Folks client in Python. Thanks again for
> > the fast fix for my last issue.
> > 
> > Since I had some trouble getting folks 0.6.6 running on Ubuntu 11.10, I
> > just upgraded to 12.04, which has folks 0.6.6. Now I am trying again to
> > digg into the python/Folks combo.
> > 
> > I tried with this simple test script:
> > 
> > ----8<----
> > from gi.repository import GObject
> > from gi.repository import Folks
> > 
> > 
> > def list_individuals():
> >     for key in aggregator.props.individuals.props.keys:
> >         print aggregator.props.individuals.get(key)
> > 
> > aggregator = Folks.IndividualAggregator.new()
> > aggregator.prepare(None, None)
> > 
> > GObject.timeout_add(2000, list_individuals)
> > 
> > main_loop = GObject.MainLoop()
> > main_loop.run()
> > ---->8----
> > 
> > Now I get this traceback:
> > 
> > Traceback (most recent call last):
> >   File "folkstest.py", line 6, in list_individuals
> >     for key in aggregator.props.individuals.props.keys:
> > TypeError: '__main__.GeeHashMapKeySet' object is not iterable
> > 
> > So the gee bindings seem not to work the python way. I read the gee API
> > doc, and then came up with something I had hoped would work:
> > 
> > ----8<----
> > def list_individuals():
> >     iterator = aggregator.props.individuals.props.keys.iterator()
> >     while iterator.has_next():
> >         iterator.next()
> >         key = iterator.get()
> >         print aggregator.props.individuals.get(key)
> > ---->8----
> > 
> > This, however, segfaults. The issue seems to be the iterator.get()
> > method call. I tried to get a backtrace using gdb, but since my
> > debugging skills are very limited, I am not sure how useful it is. I
> > attached it anyways, if you need more information, please just let me
> > know.
> 
> You should be able to trim the code down to:
> 
> while iterator.next():
>     key = iterator.get()
>     print aggregator.props.individuals.get(key)

Okay, I changed my sample script accordingly. Thanks for the hint.
However, still segfaulting.

> To my untrained eye, it looks like Python doesn't like the code, though,
> since the stack trace contains a call to "PyErr_Print". If you inspected
> this frame more closely (e.g. "frame 48; info locals" in gdb) that might
> give a hint.
> 
> In any case, could you use the "backtrace full" command in gdb to get a
> more detailed stack trace please?

I did this, please see the attached backtrace.

> > Now I don’t know if I just used the API incorrectly, or if gee just does
> > not work from Python. But I still hope to use Folks from python, and I
> > wanted to investigate a bit further, before I ditch everything and start
> > all over with vala.
> 
> Don't give up! Every problem which gets fixed as a result of using folks
> from Python will help everyone.

You’re right. I just can be frustrating at times to spend all the time
getting the prerequisites up and running, instead of actually writing
code for the project.

Anyway, thank you for your help!

Regards
Frederik
-------------- next part --------------
Starting program: /usr/bin/python folkstest2.py
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1".
[New Thread 0xb7ad2b70 (LWP 14089)]
[New Thread 0xb70ffb70 (LWP 14090)]
[New Thread 0xb68feb70 (LWP 14091)]
[New Thread 0xb60fdb70 (LWP 14092)]
[Thread 0xb7ad2b70 (LWP 14089) exited]
[Thread 0xb70ffb70 (LWP 14090) exited]
[New Thread 0xb70ffb70 (LWP 14095)]
[New Thread 0xb7ad2b70 (LWP 14096)]
[New Thread 0xb58fcb70 (LWP 14097)]
[New Thread 0xb50fbb70 (LWP 14098)]
[New Thread 0xb48fab70 (LWP 14099)]
[New Thread 0xb40f9b70 (LWP 14100)]
[New Thread 0xb38f8b70 (LWP 14101)]
[New Thread 0xb30f7b70 (LWP 14102)]
[New Thread 0xb28f6b70 (LWP 14103)]
[Thread 0xb70ffb70 (LWP 14095) exited]
[Thread 0xb7ad2b70 (LWP 14096) exited]
[Thread 0xb38f8b70 (LWP 14101) exited]
[Thread 0xb58fcb70 (LWP 14097) exited]
[Thread 0xb28f6b70 (LWP 14103) exited]
[Thread 0xb30f7b70 (LWP 14102) exited]
[Thread 0xb68feb70 (LWP 14091) exited]
[Thread 0xb48fab70 (LWP 14099) exited]
[Thread 0xb40f9b70 (LWP 14100) exited]

Program received signal SIGSEGV, Segmentation fault.
0x0812d40b in visit_decref ()
#0  0x0812d40b in visit_decref ()
No locals.
#1  0x080b9a6c in tupletraverse ()
No locals.
#2  0x0812d624 in collect ()
No locals.
#3  0x0812e179 in _PyObject_GC_Malloc ()
No locals.
#4  0x0812e1f5 in _PyObject_GC_NewVar ()
No locals.
#5  0x080ba2e6 in PyTuple_New ()
No locals.
#6  0x080fbbaa in PyEval_EvalFrameEx ()
No locals.
#7  0x080fd7e8 in PyEval_EvalCodeEx ()
No locals.
#8  0x080fe187 in PyEval_EvalCode ()
No locals.
#9  0x08111ee2 in PyImport_ExecCodeModuleEx ()
No locals.
#10 0x081120ff in load_source_module ()
No locals.
#11 0x08112d69 in import_submodule ()
No locals.
#12 0x08113011 in load_next ()
No locals.
#13 0x08113759 in import_module_level ()
No locals.
#14 0x08113dd1 in PyImport_ImportModuleLevel ()
No locals.
#15 0x080f5aef in builtin___import__ ()
No locals.
#16 0x0805dd01 in PyObject_Call ()
No locals.
#17 0x080f702e in PyEval_CallObjectWithKeywords ()
No locals.
#18 0x080f987d in PyEval_EvalFrameEx ()
No locals.
#19 0x080fd7e8 in PyEval_EvalCodeEx ()
No locals.
#20 0x080fe187 in PyEval_EvalCode ()
No locals.
#21 0x08111ee2 in PyImport_ExecCodeModuleEx ()
No locals.
#22 0x081120ff in load_source_module ()
No locals.
#23 0x08112d69 in import_submodule ()
No locals.
#24 0x08113011 in load_next ()
No locals.
#25 0x08113759 in import_module_level ()
No locals.
#26 0x08113dd1 in PyImport_ImportModuleLevel ()
No locals.
#27 0x080f5aef in builtin___import__ ()
No locals.
#28 0x0805dd01 in PyObject_Call ()
No locals.
#29 0x080f702e in PyEval_CallObjectWithKeywords ()
No locals.
#30 0x080f987d in PyEval_EvalFrameEx ()
No locals.
#31 0x080fd7e8 in PyEval_EvalCodeEx ()
No locals.
#32 0x080fe187 in PyEval_EvalCode ()
No locals.
#33 0x08111ee2 in PyImport_ExecCodeModuleEx ()
No locals.
#34 0x081120ff in load_source_module ()
No locals.
#35 0x08112d69 in import_submodule ()
No locals.
#36 0x08113011 in load_next ()
No locals.
#37 0x08113759 in import_module_level ()
No locals.
#38 0x08113dd1 in PyImport_ImportModuleLevel ()
No locals.
#39 0x080f5aef in builtin___import__ ()
No locals.
#40 0x0805dd01 in PyObject_Call ()
No locals.
#41 0x080f702e in PyEval_CallObjectWithKeywords ()
No locals.
#42 0x080f987d in PyEval_EvalFrameEx ()
No locals.
#43 0x080fd7e8 in PyEval_EvalCodeEx ()
No locals.
#44 0x0808c602 in function_call ()
No locals.
#45 0x0805dd01 in PyObject_Call ()
No locals.
#46 0x080f702e in PyEval_CallObjectWithKeywords ()
No locals.
#47 0x0811bea4 in PyErr_PrintEx ()
No locals.
#48 0x0811c0cf in PyErr_Print ()
No locals.
#49 0x006a2175 in _pyglib_handler_marshal (user_data=0xb7b8fcec)
    at /build/buildd/pygobject-3.0.3/gi/_glib/pyglib.c:535
        tuple = (<function at remote 0xb7b8d5a4>, ())
        ret = 0x0
        res = <optimized out>
        state = PyGILState_LOCKED
        __PRETTY_FUNCTION__ = "_pyglib_handler_marshal"
#50 0x005f044f in g_timeout_dispatch (source=0x83e5418, 
    callback=0x6a20a0 <_pyglib_handler_marshal>, user_data=0xb7b8fcec)
    at /build/buildd/glib2.0-2.31.10/./glib/gmain.c:3857
        timeout_source = 0x83e5418
        again = <optimized out>
#51 0x005ef6ea in g_main_dispatch (context=0x83d91c0)
    at /build/buildd/glib2.0-2.31.10/./glib/gmain.c:2513
        dispatch = 0x5f0420 <g_timeout_dispatch>
        was_in_call = 0
        user_data = 0xb7b8fcec
        callback = 0x6a20a0 <_pyglib_handler_marshal>
        cb_funcs = 0x69f4d8
        cb_data = 0x83e5460
        current_source_link = {data = 0x83e5418, next = 0x0}
        need_destroy = <optimized out>
        source = 0x83e5418
        current = 0x83d5120
        i = <optimized out>
#52 g_main_context_dispatch (context=0x83d91c0)
    at /build/buildd/glib2.0-2.31.10/./glib/gmain.c:3050
No locals.
#53 0x005efaf5 in g_main_context_iterate (dispatch=1, block=6280320, context=
    0x83d91c0, self=<optimized out>)
    at /build/buildd/glib2.0-2.31.10/./glib/gmain.c:3121
        timeout = 916
        some_ready = 1
        fds = 0x8402f90
        max_priority = 2147483647
        nfds = <optimized out>
        allocated_nfds = <optimized out>
#54 g_main_context_iterate (context=0x83d91c0, block=6280320, dispatch=1, 
    self=<optimized out>) at /build/buildd/glib2.0-2.31.10/./glib/gmain.c:3058
        some_ready = 1
#55 0x005eff3b in g_main_loop_run (loop=0x83e5478)
    at /build/buildd/glib2.0-2.31.10/./glib/gmain.c:3315
        __PRETTY_FUNCTION__ = "g_main_loop_run"
#56 0x008991b8 in _wrap_g_main_loop_run (self=0xb7fd5320)
    at /build/buildd/pygobject-3.0.3/gi/_glib/pygmainloop.c:334
        _save = 0x0
        prev_loop = 0x0
#57 0x080f8958 in PyEval_EvalFrameEx ()
No locals.
#58 0x080fd7e8 in PyEval_EvalCodeEx ()
No locals.
#59 0x080fe187 in PyEval_EvalCode ()
No locals.
#60 0x0811ad10 in run_mod ()
No locals.
#61 0x0811b929 in PyRun_FileExFlags ()
No locals.
#62 0x0811c47c in PyRun_SimpleFileExFlags ()
No locals.
#63 0x0812c7f6 in Py_Main ()
No locals.
#64 0x0805dadb in main ()
No locals.
quit
A debugging session is active.

	Inferior 1 [process 14086] will be killed.

Quit anyway? (y or n) 


More information about the telepathy mailing list