Set module name for Spam/__init__.pyx to Spam.
authorJason Evans <jasone@canonware.com>
Sat, 20 Dec 2008 00:50:47 +0000 (16:50 -0800)
committerJason Evans <jasone@canonware.com>
Sat, 20 Dec 2008 00:50:47 +0000 (16:50 -0800)
Cython/Compiler/Symtab.py

index 0f3388d171907c98bb0d7c699cd94c47e71706ae..ee9e8b7eaf68753edf08d97014948572ac051764 100644 (file)
@@ -805,7 +805,12 @@ class ModuleScope(Scope):
         self.parent_module = parent_module
         outer_scope = context.find_submodule("__builtin__")
         Scope.__init__(self, name, outer_scope, parent_module)
-        self.module_name = name
+        if name != "__init__":
+            self.module_name = name
+        else:
+            # Treat Spam/__init__.pyx specially, so that when Python loads
+            # Spam/__init__.so, initSpam() is defined.
+            self.module_name = parent_module.module_name
         self.context = context
         self.module_cname = Naming.module_cname
         self.module_dict_cname = Naming.moddict_cname