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 <wking@tremily.us>
This commit is contained in:
W. Trevor King
2012-10-25 14:15:10 -04:00
parent cd643a3d70
commit cce9f79905

View File

@@ -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;
}