Prevent reference leak in Py_BuildValue in the Python wrapper.

This commit is contained in:
Ghislain MARY 2014-08-19 17:25:48 +02:00
parent 031f335135
commit 137688ce30

View file

@ -349,7 +349,7 @@ class MethodDefinition:
else:
result_variable = 'cresult'
if result_variable != '':
build_value_code = "pyret = Py_BuildValue(\"{fmt}\", {result_variable});\n".format(fmt=self.build_value_format, result_variable=result_variable)
build_value_code = "pyret = Py_BuildValue(\"{fmt}\", {result_variable});\n".format(fmt=self.build_value_format.replace('O', 'N'), result_variable=result_variable)
body = \
""" {c_function_call_code}
pylinphone_dispatch_messages();
@ -374,12 +374,7 @@ class MethodDefinition:
def format_return_result(self):
if self.return_complete_type != 'void':
if self.build_value_format == 'O':
return \
""" Py_DECREF(pyresult);
return pyret;"""
else:
return "\treturn pyret;"
return "\treturn pyret;"
return "\tPy_RETURN_NONE;"
def format_return_none_trace(self):
@ -755,7 +750,7 @@ class EventCallbackMethodDefinition(MethodDefinition):
PyErr_Print();
}}
}}
""".format(fmt=fmt, args=args)
""".format(fmt=fmt.replace('O', 'N'), args=args)
def format_return_trace(self):
return "\tpylinphone_trace(-1, \"[PYLINPHONE] <<< %s\", __FUNCTION__);\n"