From cce9f799058baf500e67c802d7566b4e7e616fb9 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 25 Oct 2012 14:15:10 -0400 Subject: [PATCH] config: return -1 on error in Config_foreach_callback_wrapper(). Config_foreach_callback_wrapper is supposed to return 0 on success. From the docstring: As soon as one of the callbacks returns an integer other than 0, this function returns that value. If we've already had an exception, we want to bail immediately and raise the exception. Signed-off-by: W. Trevor King --- src/pygit2/config.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pygit2/config.c b/src/pygit2/config.c index f50a5e4..cd21342 100644 --- a/src/pygit2/config.c +++ b/src/pygit2/config.c @@ -223,20 +223,20 @@ Config_foreach_callback_wrapper(const git_config_entry *entry, void *c_payload) int c_result; if (!PyArg_ParseTuple(args, "O|O", &py_callback, &py_payload)) - return 0; + return -1; if (py_payload) args = Py_BuildValue("ssO", entry->name, entry->value, py_payload); else args = Py_BuildValue("ss", entry->name, entry->value); if (!args) - return 0; + return -1; if (!(py_result = PyObject_CallObject(py_callback,args))) - return 0; + return -1; if (!(c_result = PyLong_AsLong(py_result))) - return 0; + return -1; return c_result; }