fix embedding (cython-unstable allocates string constants at code-gen time)
authorStefan Behnel <scoder@users.berlios.de>
Mon, 4 May 2009 19:22:33 +0000 (21:22 +0200)
committerStefan Behnel <scoder@users.berlios.de>
Mon, 4 May 2009 19:22:33 +0000 (21:22 +0200)
Cython/Compiler/ModuleNode.py

index 2b7413e34562f2bb051d60b38be3d92cac4e8481..0b7eb86bcba31a48b7374d513bd67f48184f35a2 100644 (file)
@@ -55,8 +55,6 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
         else:
             env.doc = self.doc
         env.directives = self.directives
-        if Options.embed:
-            self.__main__cname = env.intern_identifier(EncodedString("__main__"))
         self.body.analyse_declarations(env)
     
     def process_implementation(self, options, result):
@@ -1808,10 +1806,12 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
                 Naming.builtins_cname,
                 code.error_goto(self.pos)))
         if Options.embed:
+            __main__cname = code.globalstate.get_py_string_const(
+                EncodedString("__main__"), identifier=True)
             code.putln(
                 'if (__Pyx_SetAttrString(%s, "__name__", %s) < 0) %s;' % (
                     env.module_cname,
-                    self.__main__cname,
+                    __main__cname,
                     code.error_goto(self.pos)))
         if Options.pre_import is not None:
             code.putln(