Commit 06695a0e authored by Stefan Behnel's avatar Stefan Behnel

fix embedding (cython-unstable allocates string constants at code-gen time)

parent cd3a0429
...@@ -55,8 +55,6 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -55,8 +55,6 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
else: else:
env.doc = self.doc env.doc = self.doc
env.directives = self.directives env.directives = self.directives
if Options.embed:
self.__main__cname = env.intern_identifier(EncodedString("__main__"))
self.body.analyse_declarations(env) self.body.analyse_declarations(env)
def process_implementation(self, options, result): def process_implementation(self, options, result):
...@@ -1808,10 +1806,12 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1808,10 +1806,12 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
Naming.builtins_cname, Naming.builtins_cname,
code.error_goto(self.pos))) code.error_goto(self.pos)))
if Options.embed: if Options.embed:
__main__cname = code.globalstate.get_py_string_const(
EncodedString("__main__"), identifier=True)
code.putln( code.putln(
'if (__Pyx_SetAttrString(%s, "__name__", %s) < 0) %s;' % ( 'if (__Pyx_SetAttrString(%s, "__name__", %s) < 0) %s;' % (
env.module_cname, env.module_cname,
self.__main__cname, __main__cname,
code.error_goto(self.pos))) code.error_goto(self.pos)))
if Options.pre_import is not None: if Options.pre_import is not None:
code.putln( code.putln(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment