problem using import from PyRun_String

Patrick Stinson patrickkidd.lists at gmail.com
Tue Apr 8 21:01:18 EDT 2008


I'm creating a module with PyModule_New(), and running a string buffer as
the module's text using PyRun_String and passing the module's __dict__ to
locals and globals. I'm having a problem using the import statement from
within PyRun_String(). It complains about "__import__ not found", which
after a quick grep it looks like the exception is raised from
PyExc_EvalFrameEx() in ceval.c after f->f_builtins module doesn't contain
"__import__".
What __builtin__ module does that point to? a quick print of the content of
__builtin__ in CPython code shows a function for the "__import__" key, and I
manually added all of the contents of __builtin__ to the module's dict,
which was empty before.

Any help?

Cheers

-- 
Patrick Kidd Stinson
http://www.patrickkidd.com/
http://pkaudio.sourceforge.net/
http://pksampler.sourceforge.net/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080408/9af00a47/attachment.html>


More information about the Python-list mailing list