Re: [PATCH v2 7/7] bindings/python-cffi: handle NOTMUCH_STATUS_OPERATION_INVALIDATED

Subject: Re: [PATCH v2 7/7] bindings/python-cffi: handle NOTMUCH_STATUS_OPERATION_INVALIDATED

Date: Sat, 09 Aug 2025 08:06:57 -0300

To: Anton Khirnov, notmuch@notmuchmail.org

Cc:

From: David Bremner


Anton Khirnov <anton@khirnov.net> writes:

>      def __init__(self, parent, iter_p,
> -                 *, fn_destroy, fn_valid, fn_get, fn_next):
> +                 *, fn_destroy, fn_valid, fn_get, fn_next,
> +                 fn_status = None):
> +        # exactly one of those must be provided
> +        assert(bool(fn_valid) != bool(fn_status))
> +

This might be a bit too clever, it definitely took me a minute to
decode.

> +    def _check_status(self):
> +        if self._fn_valid:
> +            if not self._fn_valid(self._iter_p):
> +                raise StopIteration

I think this needs a bit of commentary. I suppose this branch is only
run for iterators without notmuch_*_status function, but it isn't
clear. 

> +        else:
> +            status = self._fn_status(self._iter_p)
> +            if status == capi.lib.NOTMUCH_STATUS_ITERATOR_EXHAUSTED:
> +                raise StopIteration
> +            elif status > 0:

the rest of the bindings seem to prefer

    status != capi.lib.NOTMUCH_STATUS_SUCCESS:

_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: