Fix for embed and freeze which were broken by #216.
authorRobert Bradshaw <robertwb@math.washington.edu>
Sun, 4 Oct 2009 04:09:58 +0000 (21:09 -0700)
committerRobert Bradshaw <robertwb@math.washington.edu>
Sun, 4 Oct 2009 04:09:58 +0000 (21:09 -0700)
Cython/Compiler/ModuleNode.py

index b007d1cf163f5dc0e6db51ba7fab4db9646aec18..5552b521cb3b031f6186b1f8034994c04fbb1351 100644 (file)
@@ -1678,6 +1678,14 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
         code.putln("/*--- Initialize various global constants etc. ---*/")
         code.putln(code.error_goto_if_neg("__Pyx_InitGlobals()", self.pos))
 
+        code.putln("if (%s%s) {" % (Naming.module_is_main, self.full_module_name.replace('.', '__')))
+        code.putln(
+            'if (__Pyx_SetAttrString(%s, "__name__", %s) < 0) %s;' % (
+                env.module_cname,
+                self.__main__cname,
+                code.error_goto(self.pos)))
+        code.putln("}")
+
         if Options.cache_builtins:
             code.putln("/*--- Builtin init code ---*/")
             code.putln(code.error_goto_if_neg("__Pyx_InitCachedBuiltins()",
@@ -1855,13 +1863,6 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
                 env.module_cname,
                 Naming.builtins_cname,
                 code.error_goto(self.pos)))
-        code.putln("if (%s%s) {" % (Naming.module_is_main, self.full_module_name.replace('.', '__')))
-        code.putln(
-            'if (__Pyx_SetAttrString(%s, "__name__", %s) < 0) %s;' % (
-                env.module_cname,
-                self.__main__cname,
-                code.error_goto(self.pos)))
-        code.putln("}")
         if Options.pre_import is not None:
             code.putln(
                 '%s = PyImport_AddModule(__Pyx_NAMESTR("%s"));' % (