Hello,

Intra-package reference 
(http://docs.python.org/tutorial/modules.html#intra-package-references) does 
not work with cimport.

foo.py:
def foo():
    pass

bar.py:
import foo
foo.foo()

If I move foo.py and bar.py into a package and import pkg.bar, it works under 
Python as well as under Cython.

But if I "cimport foo" (cdef foo), it works when not in a package, but fails to 
import foo when in pkg.

Looking at the generated code, I see that "import foo" is mapped to
  PyObject_CallFunction(__import__, ...
using the module as globals (why not using PyImport_ImportModuleEx()?),

whereas "cimport foo" uses PyImport_Import(), that lets globals to NULL, so the 
issue.

Is there a reason that cimport is mapped differently?

Cheers,
Stephane

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to