[Telepathy] Accessing Folks from python, part 2

Frederik Elwert frederik.elwert at web.de
Mon Jan 23 01:22:49 PST 2012


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.

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.

So if anybody has any idea or advice, I’d be thankful.

Regards
Frederik
-------------- next part --------------
A non-text attachment was scrubbed...
Name: folkstest.py
Type: text/x-python
Size: 371 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/telepathy/attachments/20120123/d13b7693/attachment.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: folkstest2.py
Type: text/x-python
Size: 465 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/telepathy/attachments/20120123/d13b7693/attachment-0001.py>
-------------- next part --------------
(gdb) run folkstest2.py
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 6887)]
[New Thread 0xb70ffb70 (LWP 6888)]
[New Thread 0xb68feb70 (LWP 6889)]
[New Thread 0xb60fdb70 (LWP 6890)]
[Thread 0xb7ad2b70 (LWP 6887) exited]
[Thread 0xb68feb70 (LWP 6889) exited]
[New Thread 0xb68feb70 (LWP 6894)]
[New Thread 0xb7ad2b70 (LWP 6895)]
[New Thread 0xb58fcb70 (LWP 6896)]
[New Thread 0xb50fbb70 (LWP 6897)]
[New Thread 0xb48fab70 (LWP 6898)]
[New Thread 0xb40f9b70 (LWP 6899)]
[New Thread 0xb38f8b70 (LWP 6900)]
[New Thread 0xb30f7b70 (LWP 6901)]
[New Thread 0xb28f6b70 (LWP 6902)]
[Thread 0xb50fbb70 (LWP 6897) exited]
[Thread 0xb30f7b70 (LWP 6901) exited]
[Thread 0xb70ffb70 (LWP 6888) exited]
[Thread 0xb40f9b70 (LWP 6899) exited]
[Thread 0xb38f8b70 (LWP 6900) exited]
[Thread 0xb28f6b70 (LWP 6902) exited]
[Thread 0xb7ad2b70 (LWP 6895) exited]
[Thread 0xb68feb70 (LWP 6894) exited]
[Thread 0xb48fab70 (LWP 6898) exited]

Program received signal SIGSEGV, Segmentation fault.
0x0812d40b in visit_decref ()
(gdb) bt
#0  0x0812d40b in visit_decref ()
#1  0x080b9a6c in tupletraverse ()
#2  0x0812d624 in collect ()
#3  0x0812e179 in _PyObject_GC_Malloc ()
#4  0x0812e1f5 in _PyObject_GC_NewVar ()
#5  0x080ba2e6 in PyTuple_New ()
#6  0x080fbbaa in PyEval_EvalFrameEx ()
#7  0x080fd7e8 in PyEval_EvalCodeEx ()
#8  0x080fe187 in PyEval_EvalCode ()
#9  0x08111ee2 in PyImport_ExecCodeModuleEx ()
#10 0x081120ff in load_source_module ()
#11 0x08112d69 in import_submodule ()
#12 0x08113011 in load_next ()
#13 0x08113759 in import_module_level ()
#14 0x08113dd1 in PyImport_ImportModuleLevel ()
#15 0x080f5aef in builtin___import__ ()
#16 0x0805dd01 in PyObject_Call ()
#17 0x080f702e in PyEval_CallObjectWithKeywords ()
#18 0x080f987d in PyEval_EvalFrameEx ()
#19 0x080fd7e8 in PyEval_EvalCodeEx ()
#20 0x080fe187 in PyEval_EvalCode ()
#21 0x08111ee2 in PyImport_ExecCodeModuleEx ()
#22 0x081120ff in load_source_module ()
#23 0x08112d69 in import_submodule ()
#24 0x08113011 in load_next ()
#25 0x08113759 in import_module_level ()
#26 0x08113dd1 in PyImport_ImportModuleLevel ()
#27 0x080f5aef in builtin___import__ ()
#28 0x0805dd01 in PyObject_Call ()
#29 0x080f702e in PyEval_CallObjectWithKeywords ()
#30 0x080f987d in PyEval_EvalFrameEx ()
#31 0x080fd7e8 in PyEval_EvalCodeEx ()
#32 0x080fe187 in PyEval_EvalCode ()
#33 0x08111ee2 in PyImport_ExecCodeModuleEx ()
#34 0x081120ff in load_source_module ()
#35 0x08112d69 in import_submodule ()
#36 0x08113011 in load_next ()
#37 0x08113759 in import_module_level ()
#38 0x08113dd1 in PyImport_ImportModuleLevel ()
#39 0x080f5aef in builtin___import__ ()
#40 0x0805dd01 in PyObject_Call ()
#41 0x080f702e in PyEval_CallObjectWithKeywords ()
#42 0x080f987d in PyEval_EvalFrameEx ()
#43 0x080fd7e8 in PyEval_EvalCodeEx ()
#44 0x0808c602 in function_call ()
#45 0x0805dd01 in PyObject_Call ()
#46 0x080f702e in PyEval_CallObjectWithKeywords ()
#47 0x0811bea4 in PyErr_PrintEx ()
#48 0x0811c0cf in PyErr_Print ()
#49 0x006a2175 in _pyglib_handler_marshal (user_data=0xb7b8fd0c)
    at /build/buildd/pygobject-3.0.3/gi/_glib/pyglib.c:535
#50 0x005f044f in ?? () from /lib/i386-linux-gnu/libglib-2.0.so.0
#51 0x005ef6ea in g_main_context_dispatch ()
   from /lib/i386-linux-gnu/libglib-2.0.so.0
#52 0x005efaf5 in ?? () from /lib/i386-linux-gnu/libglib-2.0.so.0
#53 0x005eff3b in g_main_loop_run () from /lib/i386-linux-gnu/libglib-2.0.so.0
#54 0x008991b8 in _wrap_g_main_loop_run (self=0xb7fd5320)
    at /build/buildd/pygobject-3.0.3/gi/_glib/pygmainloop.c:334
#55 0x080f8958 in PyEval_EvalFrameEx ()
#56 0x080fd7e8 in PyEval_EvalCodeEx ()
#57 0x080fe187 in PyEval_EvalCode ()
#58 0x0811ad10 in run_mod ()
#59 0x0811b929 in PyRun_FileExFlags ()
#60 0x0811c47c in PyRun_SimpleFileExFlags ()
#61 0x0812c7f6 in Py_Main ()
#62 0x0805dadb in main ()


More information about the telepathy mailing list