See equivalent change for OCaml in
commit d881d160e1cd9c9964782300a7652ffb4e506c27.
If the Python callback doesn't return something which looks like an
integer, assume 0 instead of returning an error.
---
generator/generator | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/generator/generator b/generator/generator
index 55c4dfc..e5d9aaa 100755
--- a/generator/generator
+++ b/generator/generator
@@ -4234,7 +4234,12 @@ let print_python_binding name { args; optargs; ret; may_set_error }
=
pr " Py_DECREF (py_args);\n";
pr "\n";
pr " if (py_ret != NULL) {\n";
- pr " Py_DECREF (py_ret); /* return value is discarded */\n";
+ pr " if (PyLong_Check (py_ret))\n";
+ pr " ret = PyLong_AsLong (py_ret);\n";
+ pr " else\n";
+ pr " /* If it's not a long, just assume it's 0. */\n";
+ pr " ret = 0;\n";
+ pr " Py_DECREF (py_ret);\n";
pr " }\n";
pr " else {\n";
pr " ret = -1;\n";
--
2.22.0