Fix reference count problem when returning an already existing Python object from the native object user data.

This commit is contained in:
Ghislain MARY 2014-08-29 17:34:41 +02:00
parent b4978948f9
commit 53c6673032

View file

@ -329,7 +329,7 @@ class MethodDefinition:
get_user_data_function = return_type_class['class_c_function_prefix'] + "get_user_data"
return_from_user_data_code = \
"""if ((cresult != NULL) && ({func}(cresult) != NULL)) {{
return (PyObject *){func}(cresult);
return Py_BuildValue("O", (PyObject *){func}(cresult));
}}
""".format(func=get_user_data_function)
new_from_native_pointer_code = "pyresult = pylinphone_{return_type}_new_from_native_ptr(&pylinphone_{return_type}Type, cresult);\n".format(return_type=stripped_return_type)