Commit bcae4d1f authored by Stefan Behnel's avatar Stefan Behnel

Fix globals for lambda functions in limited-API mode.

parent dc3e0711
...@@ -9436,29 +9436,21 @@ class PyCFunctionNode(ExprNode, ModuleNameMixin): ...@@ -9436,29 +9436,21 @@ class PyCFunctionNode(ExprNode, ModuleNameMixin):
else: else:
flags = '0' flags = '0'
code.putln('#if CYTHON_COMPILING_IN_LIMITED_API') borrowed_moddict_temp = code.funcstate.allocate_temp(py_object_type, manage_ref=False)
dict_temp = code.funcstate.allocate_temp(py_object_type, manage_ref=True) code.putln("#if CYTHON_COMPILING_IN_LIMITED_API")
code.putln('%s = PyDict_New(); %s' % ( code.putln('%s = PyModule_GetDict(%s); %s' % (
dict_temp, borrowed_moddict_temp,
code.error_goto_if_null(dict_temp, self.pos))) Naming.module_cname,
code.put_gotref(dict_temp, py_object_type) code.error_goto_if_null(borrowed_moddict_temp, self.pos)))
code.putln( code.putln("#else")
'%s = %s(&%s, %s, %s, %s, %s, %s, %s); %s' % ( code.putln("%s = %s; if ((1)); else %s;" % (
self.result(), borrowed_moddict_temp,
constructor, Naming.moddict_cname,
self.pymethdef_cname, code.error_goto(self.pos),
flags, ))
self.get_py_qualified_name(code), code.putln("#endif")
self.closure_result_code(),
self.get_py_mod_name(code),
dict_temp,
code_object_result,
code.error_goto_if_null(self.result(), self.pos)))
code.put_decref_clear(dict_temp, type=py_object_type)
code.funcstate.release_temp(dict_temp)
code.putln('#else')
code.putln( code.putln(
'%s = %s(&%s, %s, %s, %s, %s, %s, %s); %s' % ( '%s = %s(&%s, %s, %s, %s, %s, %s, %s); %s = NULL; %s' % (
self.result(), self.result(),
constructor, constructor,
self.pymethdef_cname, self.pymethdef_cname,
...@@ -9466,10 +9458,11 @@ class PyCFunctionNode(ExprNode, ModuleNameMixin): ...@@ -9466,10 +9458,11 @@ class PyCFunctionNode(ExprNode, ModuleNameMixin):
self.get_py_qualified_name(code), self.get_py_qualified_name(code),
self.closure_result_code(), self.closure_result_code(),
self.get_py_mod_name(code), self.get_py_mod_name(code),
Naming.moddict_cname, borrowed_moddict_temp,
code_object_result, code_object_result,
borrowed_moddict_temp,
code.error_goto_if_null(self.result(), self.pos))) code.error_goto_if_null(self.result(), self.pos)))
code.putln('#endif') code.funcstate.release_temp(borrowed_moddict_temp)
self.generate_gotref(code) self.generate_gotref(code)
......
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