[pypy-dev] question on using ctypes

Jiwon Seo seojiwon at gmail.com
Wed Jul 5 10:16:27 CEST 2006


After properly installing ctypes, translate.py now gives this error.

##################################################################

[translation:ERROR] Error:
[translation:ERROR]  Traceback (most recent call last):
[translation:ERROR]    File "./translate.py", line 332, in main
[translation:ERROR]     drv.proceed(goals)
[translation:ERROR]    File
"/u/jiwon/proj/pypy-dist/pypy/translator/driver.py", line 506, in
proceed
[translation:ERROR]     return self._execute(goals, task_skip =
self._maybe_skip())
[translation:ERROR]    File
"/u/jiwon/proj/pypy-dist/pypy/translator/tool/taskengine.py", line
108, in _execute
[translation:ERROR]     res = self._do(goal, taskcallable, *args, **kwds)
[translation:ERROR]    File
"/u/jiwon/proj/pypy-dist/pypy/translator/driver.py", line 195, in _do
[translation:ERROR]     res = func()
[translation:ERROR]    File
"/u/jiwon/proj/pypy-dist/pypy/translator/driver.py", line 208, in
task_annotate
[translation:ERROR]     s = annotator.build_types(self.entry_point,
self.inputtypes)
[translation:ERROR]    File
"/u/jiwon/proj/pypy-dist/pypy/annotation/annrpython.py", line 100, in
build_types
[translation:ERROR]     return self.build_graph_types(flowgraph,
inputcells, complete_now=complete_now)
[translation:ERROR]    File
"/u/jiwon/proj/pypy-dist/pypy/annotation/annrpython.py", line 143, in
build_graph_types
[translation:ERROR]     self.complete()
[translation:ERROR]    File
"/u/jiwon/proj/pypy-dist/pypy/annotation/annrpython.py", line 188, in
complete
[translation:ERROR]     self.processblock(graph, block)
[translation:ERROR]    File
"/u/jiwon/proj/pypy-dist/pypy/annotation/annrpython.py", line 434, in
processblock
[translation:ERROR]     self.flowin(graph, block)
[translation:ERROR]    File
"/u/jiwon/proj/pypy-dist/pypy/annotation/annrpython.py", line 490, in
flowin
[translation:ERROR]     self.consider_op(block.operations[i])
[translation:ERROR]    File
"/u/jiwon/proj/pypy-dist/pypy/annotation/annrpython.py", line 661, in
consider_op
[translation:ERROR]     argcells = [self.binding(a) for a in op.args]
[translation:ERROR]    File
"/u/jiwon/proj/pypy-dist/pypy/annotation/annrpython.py", line 238, in
binding
[translation:ERROR]     return self.bookkeeper.immutableconstant(arg)
[translation:ERROR]    File
"/u/jiwon/proj/pypy-dist/pypy/annotation/bookkeeper.py", line 297, in
immutableconstant
[translation:ERROR]     return self.immutablevalue(const.value)
[translation:ERROR]    File
"/u/jiwon/proj/pypy-dist/pypy/annotation/bookkeeper.py", line 393, in
immutablevalue
[translation:ERROR]     result = SomePBC([self.getdesc(x)])
[translation:ERROR]    File
"/u/jiwon/proj/pypy-dist/pypy/annotation/bookkeeper.py", line 524, in
getdesc
[translation:ERROR]     return self.descs[pyobj]
[translation:ERROR]  TypeError: unhashable type
[translation:ERROR] Processing block:
[translation:ERROR]  block at -1 is a <class
'pypy.objspace.flow.flowcontext.SpamBlock'>
[translation:ERROR]  in (pypy.module.tcc.tcc:9)tcc_print0
[translation:ERROR]  containing the following operations:
[translation:ERROR]        v107 = simple_call((_FuncPtr TCC_Print), msg_0)
[translation:ERROR]  --end--

############# end of error message ##################################

pypy/module/tcc/__init__.py is like following
# Package initialisation
from pypy.interpreter.mixedmodule import MixedModule

class Module(MixedModule):
    appleveldefs = {}
    interpleveldefs = {
        'print0':   'tcc.tcc_print0'
    }

and pypy/module/tcc/tcc.py is like following

from pypy.interpreter.baseobjspace import ObjSpace
from ctypes import *

libtcc = CDLL('/u/jiwon/proj/less-bus/libLESS.so')
myprint0 = libtcc.TCC_Print
myprint0.argtypes = [c_char_p]
myprint0.restype = c_int

def tcc_print0(space, msg):
    return myprint0(msg)
tcc_print0.unwrap_spec = [ObjSpace, str]


What am I missing here?

-Jiwon


More information about the pypy-dev mailing list