Commit 6e670e64 authored by Stefan Behnel's avatar Stefan Behnel

make sure the global __pyx_b reference to builtins module is being kept alive in PyPy

--HG--
extra : rebase_source : dabba307e50ecd4a686f05e86dea8897c340f36d
parent 17a4208e
...@@ -1910,6 +1910,9 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1910,6 +1910,9 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
# if entry.type.is_pyobject and entry.used: # if entry.type.is_pyobject and entry.used:
# code.putln("Py_DECREF(%s); %s = 0;" % ( # code.putln("Py_DECREF(%s); %s = 0;" % (
# code.entry_as_pyobject(entry), entry.cname)) # code.entry_as_pyobject(entry), entry.cname))
code.putln('#if CYTHON_COMPILING_IN_PYPY')
code.putln('Py_CLEAR(%s);' % Naming.builtins_cname)
code.putln('#endif')
code.putln("Py_INCREF(Py_None); return Py_None;") code.putln("Py_INCREF(Py_None); return Py_None;")
def generate_main_method(self, env, code): def generate_main_method(self, env, code):
...@@ -1968,7 +1971,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1968,7 +1971,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.putln( code.putln(
"if (!%s) %s;" % ( "if (!%s) %s;" % (
env.module_cname, env.module_cname,
code.error_goto(self.pos))); code.error_goto(self.pos)))
code.putln("#if PY_MAJOR_VERSION < 3") code.putln("#if PY_MAJOR_VERSION < 3")
code.putln( code.putln(
"Py_INCREF(%s);" % "Py_INCREF(%s);" %
...@@ -1980,7 +1983,10 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1980,7 +1983,10 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.putln( code.putln(
"if (!%s) %s;" % ( "if (!%s) %s;" % (
Naming.builtins_cname, Naming.builtins_cname,
code.error_goto(self.pos))); code.error_goto(self.pos)))
code.putln('#if CYTHON_COMPILING_IN_PYPY')
code.putln('Py_INCREF(%s);' % Naming.builtins_cname)
code.putln('#endif')
code.putln( code.putln(
'if (__Pyx_SetAttrString(%s, "__builtins__", %s) < 0) %s;' % ( 'if (__Pyx_SetAttrString(%s, "__builtins__", %s) < 0) %s;' % (
env.module_cname, env.module_cname,
...@@ -1994,7 +2000,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1994,7 +2000,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.putln( code.putln(
"if (!%s) %s;" % ( "if (!%s) %s;" % (
Naming.preimport_cname, Naming.preimport_cname,
code.error_goto(self.pos))); code.error_goto(self.pos)))
def generate_global_init_code(self, env, code): def generate_global_init_code(self, env, code):
# Generate code to initialise global PyObject * # Generate code to initialise global PyObject *
......
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