From 2c748f0e65fa076023d22ba2aa4b7d97f708d249 Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Thu, 2 Apr 2009 17:39:09 -0700 Subject: [PATCH] Test for ticket #4, from package cimport module, finish fixing ticket. --- Cython/Compiler/Nodes.py | 8 ++++++-- tests/compile/a/__init__.py | 0 tests/compile/a/b.pxd | 1 + tests/compile/cimport_package_module_T4.pyx | 3 +++ 4 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 tests/compile/a/__init__.py create mode 100644 tests/compile/a/b.pxd create mode 100644 tests/compile/cimport_package_module_T4.pyx diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index f9a8e1a8..8d77c456 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -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 index 00000000..e69de29b diff --git a/tests/compile/a/b.pxd b/tests/compile/a/b.pxd new file mode 100644 index 00000000..4793acbb --- /dev/null +++ b/tests/compile/a/b.pxd @@ -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 index 00000000..54367cb6 --- /dev/null +++ b/tests/compile/cimport_package_module_T4.pyx @@ -0,0 +1,3 @@ +from a cimport b + +cdef int **t = b.foo(NULL) -- 2.26.2