Re: BUG: Python's Message.header fails for empty headers

Subject: Re: BUG: Python's Message.header fails for empty headers

Date: Tue, 09 Jan 2024 08:38:08 -0400

To: Michael J Gruber

Cc: Vojtěch Káně,

From: David Bremner

Michael J Gruber <> writes:

>> I agree the bindings documentation does not make much sense.  I suspect
>> that the bindings should follow the underlying library and return "" if
>> the library does.  I don't use the bindings that much, so I am curious
>> what others think.
> I might be misunderstanding the OP,and I didn't check the RFC, but
> isn't there a difference between a missing header and an empty header?

Are you suggesting the library should change as well?

> If there is, this may come down to the difference between testing for
> an empty string, None or False in dynamically typed python ...
> But it does make sense for the bindings to return an empty string or
> None for an empty header and LookUpError for a missing header. I have
> not checked whether our bindings in fact do.

AFAICT it checks explicitely for NULL, but then throws LookupError on
any falsy return from capi.ffi.string

        ret = capi.lib.notmuch_message_get_header(self._msg_p, name)
        if ret == capi.ffi.NULL:
            raise errors.NullPointerError()
        hdr = capi.ffi.string(ret)
        if not hdr:
            raise LookupError
        return hdr.decode(encoding='utf-8')
notmuch mailing list --
To unsubscribe send an email to