Test for ticket #4, from package cimport module, finish fixing ticket.
authorRobert Bradshaw <robertwb@math.washington.edu>
Fri, 3 Apr 2009 00:39:09 +0000 (17:39 -0700)
committerRobert Bradshaw <robertwb@math.washington.edu>
Fri, 3 Apr 2009 00:39:09 +0000 (17:39 -0700)
Cython/Compiler/Nodes.py
tests/compile/a/__init__.py [new file with mode: 0644]
tests/compile/a/b.pxd [new file with mode: 0644]
tests/compile/cimport_package_module_T4.pyx [new file with mode: 0644]

index f9a8e1a8228b01952eb80afc001ac4f370cba3cd..8d77c456b0877acdbf2551cf7669dfbc54628bf2 100644 (file)
@@ -4688,8 +4688,12 @@ class FromCImportStatNode(StatNode):
                         entry = module_scope.declare_c_class(name, pos = pos,
                             module_name = self.module_name)
                     else:
-                        error(pos, "Name '%s' not declared in module '%s'"
-                            % (name, self.module_name))
+                        submodule_scope = env.context.find_module(name, relative_to = module_scope, pos = self.pos)
+                        if submodule_scope.parent_module is module_scope:
+                            env.declare_module(as_name or name, submodule_scope, self.pos)
+                        else:
+                            error(pos, "Name '%s' not declared in module '%s'"
+                                % (name, self.module_name))
                         
                 if entry:
                     local_name = as_name or name
diff --git a/tests/compile/a/__init__.py b/tests/compile/a/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/tests/compile/a/b.pxd b/tests/compile/a/b.pxd
new file mode 100644 (file)
index 0000000..4793acb
--- /dev/null
@@ -0,0 +1 @@
+cdef int **foo(void*)
diff --git a/tests/compile/cimport_package_module_T4.pyx b/tests/compile/cimport_package_module_T4.pyx
new file mode 100644 (file)
index 0000000..54367cb
--- /dev/null
@@ -0,0 +1,3 @@
+from a cimport b
+
+cdef int **t = b.foo(NULL)