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

Augie Fackler raf at durin42.com
Wed Jan 16 09:27:29 UTC 2019


On Sun, Oct 28, 2018 at 10:11:03PM +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya at tcha.org>
> # Date 1540730473 -32400
> #      Sun Oct 28 21:41:13 2018 +0900
> # Branch stable
> # Node ID c40ceec4d993927b6788ad430dc6b4f3087d9aeb
> # Parent  28a5ec244ba88ce4a46a26a32c24fa36f7597245
> rust: propagate Python exception raised from index_get_parents_checked()

series LG, but I'll wait for the v2 with the cleaned up Result<(), ...>

>
> Spotted while testing with a bad stoprev value. The current Rust interface
> can't report inner errors.
>
> diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c
> --- a/mercurial/cext/revlog.c
> +++ b/mercurial/cext/revlog.c
> @@ -2397,7 +2397,7 @@ static void rustla_dealloc(rustlazyances
>
>  static PyObject *rustla_next(rustlazyancestorsObject *self) {
>       int res = rustlazyancestors_next(self->iter);
> -	if (res == -1) {
> +	if (res == -1 || PyErr_Occurred()) {
>               /* Setting an explicit exception seems unnecessary
>                * as examples from Python source code (Objects/rangeobjets.c and
>                * Modules/_io/stringio.c) seem to demonstrate.
> @@ -2408,10 +2408,14 @@ static PyObject *rustla_next(rustlazyanc
>  }
>
>  static int rustla_contains(rustlazyancestorsObject *self, PyObject *rev) {
> +	int res;
>       if (!(PyInt_Check(rev))) {
>               return 0;
>       }
> -	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;
>  }
>
>  static PySequenceMethods rustla_sequence_methods = {
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list