From e13a42a6e5d3a80c7ceab01aa649026be91d6841 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 25 Oct 2012 14:22:47 -0400 Subject: [PATCH] config: fix return conversion in Config_foreach_callback_wrapper() PyLong_AsLong() returns -1 on error. The previous implementation returned -1 when py_result was 0, which killed every .foreach() iteration after the first callback. We could skip the if clause and just return the result of PyLong_AsLong(), but keeping the if clause makes it more obvious that we *did* think about handling errors from PyLong_AsLong(). Signed-off-by: W. Trevor King --- src/pygit2/config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pygit2/config.c b/src/pygit2/config.c index cd21342..0cbee92 100644 --- a/src/pygit2/config.c +++ b/src/pygit2/config.c @@ -235,7 +235,7 @@ Config_foreach_callback_wrapper(const git_config_entry *entry, void *c_payload) if (!(py_result = PyObject_CallObject(py_callback,args))) return -1; - if (!(c_result = PyLong_AsLong(py_result))) + if (c_result = PyLong_AsLong(py_result) == -1) return -1; return c_result;