[pypy-dev] question on using ctypes

Amaury Forgeot d'Arc amauryfa at gmail.com
Tue Jul 4 18:26:09 CEST 2006

2006/7/4, Jiwon Seo <seojiwon at gmail.com>:
> Hi,
> I added a module that uses ctypes under pypy/module/ but I'm getting
> ImportError while running translate.py for targetpypystandalone.py
> The error message is like,
> ..... cut ...
> [translation:ERROR]     w_value = loader(space)
> [translation:ERROR]    File
> "/u/jiwon/proj/pypy-dist/pypy/interpreter/mixedmodule.py", line 135,
> in ifileloader
> [translation:ERROR]     d[name] = __import__(name, None, None, [name])
> [translation:ERROR]  ImportError': No module named tcc
> [translation:ERROR]     .. v0 = getattr(self_0, ('w_dict'))
> [translation:ERROR] Processing block:
> [translation:ERROR]  block at -1 is a <class
> 'pypy.objspace.flow.flowcontext.SpamBlock'>
> [translation:ERROR]  in
> (pypy.interpreter.mixedmodule:33)MixedModule.MixedModule.getdictvalue
> [translation:ERROR]  containing the following operations:
> [translation:ERROR]        v1 = getattr(space_0, ('finditem'))
> [translation:ERROR]        v0 = getattr(self_0, ('w_dict'))
> [translation:ERROR]        v2 = simple_call(v1, v0, w_name_0)
> [translation:ERROR]        v3 = getattr(self_0, ('lazy'))
> [translation:ERROR]        v4 = is_true(v3)
> [translation:ERROR]  --end--
> and the part I added is pypy/module/tcc/__init__.py and pypy/module/tcc/tcc.py


Don't know if it helps, but I have already seen this problem:
sometimes an ImportError can mask another ImportError.
The code in mixedmodule.py looks like this:
        d[name] = __import__(pkgroot+'.'+name, None, None, [name])
    except ImportError:
        d[name] = __import__(name, None, None, [name])

The first call is supposed to be the good one, but if it fails with an
ImportError, you get the error from the second call.
Is the ctypes module correctly installed?

Amaury Forgeot d'Arc

More information about the Pypy-dev mailing list