From: Robert Bradshaw Date: Mon, 25 Feb 2008 20:47:30 +0000 (-0800) Subject: error on local cimport (rather than traceback) X-Git-Tag: 0.9.6.14~29^2~24 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=f5aeb3754f2b175946b3cffcb784ad3b0fb421ab;p=cython.git error on local cimport (rather than traceback) --- diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index 8204427c..ce0e0fb7 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -3296,6 +3296,9 @@ class CImportStatNode(StatNode): # as_name string or None Name specified in "as" clause, if any def analyse_declarations(self, env): + if not env.is_module_scope: + error(self.pos, "cimport only allowed at module level") + return module_scope = env.find_module(self.module_name, self.pos) if "." in self.module_name: names = self.module_name.split(".") @@ -3328,6 +3331,9 @@ class FromCImportStatNode(StatNode): # imported_names [(pos, name, as_name)] Names to be imported def analyse_declarations(self, env): + if not env.is_module_scope: + error(self.pos, "cimport only allowed at module level") + return module_scope = env.find_module(self.module_name, self.pos) env.add_imported_module(module_scope) for pos, name, as_name in self.imported_names: