[PATCH 3 of 3 STABLE] rust: propagate Python exception raised from index_get_parents_checked()

Yuya Nishihara yuya at tcha.org
Tue Oct 30 19:04:41 EDT 2018


On Tue, 30 Oct 2018 15:48:43 +0100, Georges Racinet wrote:
> On 10/29/2018 02:03 PM, Yuya Nishihara wrote:
> >> -	return rustlazyancestors_contains(self->iter, PyInt_AS_LONG(rev));
> >> +	res = rustlazyancestors_contains(self->iter, PyInt_AS_LONG(rev));
> >> +	if (PyErr_Occurred())
> >> +		return -1;
> >> +	return res;
> > Not that a proper fix is to make AncestorsIterator functions return
> > Result<_, GraphError>. I can send the patch for stable if it's preferred.
> Returning Result<_, GraphError> as much as possible is my intent indeed,
> but it wouldn't apply to next(), because the Iterator trait does not
> allow for that, unless we change the signature to an Iterator with Item
> = Result<Revision, GraphError>. I didn't dare to do that earlier, as it
> seemed to be too heavy.
> 
> That being said, I'm not sure how much of these errors (bad stoprev etc)
> we can get rid of from the start. The more serious case would be that of
> the corrupted index, though, in which a correct initialization can still
> give rise to errors later on.

Yes, that's the reason we need an iterator yielding Result type. We can't
guarantee that the index content is valid.


More information about the Mercurial-devel mailing list