[Pyrex] Pyrex importing question.

Greg Ewing greg.ewing at canterbury.ac.nz
Mon Nov 15 04:22:54 CET 2004


Blake Winton wrote:
> This leads me to believe that the
> "import conduit.ConduitImpl" line is failing, but I don't know of any 
> particularly good way to find out how or why.

Are you importing the Pyrex module in the normal way
from Python code (or another Pyrex module), or are you
doing something tricky like loading and calling it
directly from C code? If the latter, you're into
unsupported territory, and I can't guarantee what
will happen.

In particular, if the Pyrex module's init function
doesn't get called, access to builtins (including
__import__) won't work. Normally it gets called
automatically when the module is imported, but if
you're bypassing the import mechanism somehow, you
may need to call it manually.

> There's a thread at:
> http://groups.google.com/groups?hl=en&lr=&threadm=mailman.1028062003.32422.python-list%40python.org&rnum=1&prev=/groups%3Fq%3Dpyrex%2Bpy2exe%2Bimport%26hl%3Den%26btnG%3DGoogle%2BSearch 
> 
> specifically it suggests that Pyrex should use 
> PyImport_ImportModuleEx() instead of __import__.

I seem to remember looking through the Python/C API
for something suitable, but couldn't find anything
that performed all the functions of __import__.
I'll take a look at this.

But in any case, even if this solves your import
problem, if the cause is what I suggested (i.e.
the init function not being called) then you are
likely to have other problems as well.

-- 
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg at cosc.canterbury.ac.nz	   +--------------------------------------+




More information about the Pyrex mailing list