Skip to content

Commit

Permalink
Handle errors while building the list gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
richo committed Jan 4, 2013
1 parent 77224e4 commit b652442
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/pygit2/repository.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,13 @@ Repository_contains(Repository *self, PyObject *value)
static int
Repository_build_as_iter(git_oid *oid, PyObject *accum)
{
PyList_Append(accum, git_oid_to_py_str(oid));
int err;

err = PyList_Append(accum, git_oid_to_py_str(oid));
if (err < 0) {
Error_set(err);
return -1;
}
return 0;
}

Expand All @@ -181,7 +187,10 @@ Repository_as_iter(Repository *self)
return -1;
}
err = git_odb_foreach(odb, Repository_build_as_iter, accum);
if (err < 0) {
if (err == GIT_EUSER) {
git_odb_free(odb);
return -1;
} else if (err < 0) {
git_odb_free(odb);
Error_set(err);
return -1;
Expand Down

0 comments on commit b652442

Please sign in to comment.