diff options
Diffstat (limited to 'libunbound/python/libunbound.i')
| -rw-r--r-- | libunbound/python/libunbound.i | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/libunbound/python/libunbound.i b/libunbound/python/libunbound.i index a23c45b9c708..763879e80869 100644 --- a/libunbound/python/libunbound.i +++ b/libunbound/python/libunbound.i @@ -916,7 +916,13 @@ int _ub_resolve_async(struct ub_ctx* ctx, char* name, int rrtype, int rrclass, v struct cb_data* id; id = (struct cb_data*) iddata; arglist = Py_BuildValue("(OiO)",id->data,status, SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ub_result, 0 | 0 )); // Build argument list +#if PY_MAJOR_VERSION <= 2 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 9) + /* for python before 3.9 */ fresult = PyEval_CallObject(id->func,arglist); // Call Python +#else + /* for python 3.9 and newer */ + fresult = PyObject_Call(id->func,arglist,NULL); +#endif Py_DECREF(id->func); Py_DECREF(id->data); free(id); @@ -930,6 +936,8 @@ int _ub_resolve_async(struct ub_ctx* ctx, char* name, int rrtype, int rrclass, v int r; struct cb_data* id; id = (struct cb_data*) malloc(sizeof(struct cb_data)); + if(!id) + return -2; /* UB_NOMEM */ id->data = mydata; id->func = pyfunc; |
