From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:700:3204::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id GK0BLw9CnWVvCwEAkFu2QA (envelope-from ) for ; Tue, 09 Jan 2024 13:54:39 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id aFQNJw9CnWXAywAAe85BDQ (envelope-from ) for ; Tue, 09 Jan 2024 13:54:39 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20230601 header.b=bTv3qeju; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1704804879; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-owner:list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=8+IjXdhdEtZjFsT5KGy2XEDLFpL4jsbsn8oUut427Lg=; b=U9YWuIUZZJxwVDVrVHNhF8LwoFF2/RkRQ9++h8twXHJfiPsNe50bTkmcwEJGnUDtGdkCZz COPEQtZrfcZOl78lUAqq0AgUasRP3X9DaZKT82LbU/gX9oqdckCqNKxWURNIKUstVilVpO 3edUVwemgJzmjFpv8S+INaKf0lO8dPYX/3GO8ufMxtazhdaU0Q7eP/gYPzWRaJWw7c570C fcuhiXUseB1WNEcpboJIMYVHH0REaZBEph+CINGtutgDH370cAZbbuDUeQidTgK6WSLXbA 6dpfCWdYQ7HRYfGetjZaEC5rtxyVpLjVAIVMz0HkQzR9sPwgyp2/9fhgVZBjsA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1704804879; a=rsa-sha256; cv=none; b=uvCdOW8CTuUikA3YR91lOjSlPu6jh34JKwJUzXUORfAolENgLB70owXFUZH+gQpJwV/1s5 Tf5UqGmS9uvFsYeNWeaXo7+n6bnsyBm1bI2ntFJ4HqyaVkQkIJT9psgXAKYbWC9Jc9Vmz8 MH6S3tbcXZY8Ybxrc2RSj23EZya+dTxtuquw+ZJa4uGaCQ2C31TMqaDXg9B7ELZ3wIsOnD N2b9GAd7vvMOgM3k825/a7VUtD8eeLXHK0E3WAKfqLWShWDh6t1mYlUpk63rsQZqavI3qD FNPldygSao1ZFhlabUuZ5+i36ranQsTw0IIR1CwtSPefNDM2PjAdv9NIWPYrJQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20230601 header.b=bTv3qeju; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none) Received: from mail.notmuchmail.org (yantan.tethera.net [135.181.149.255]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 59100B930 for ; Tue, 9 Jan 2024 13:54:39 +0100 (CET) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id DD3555F7C3; Tue, 9 Jan 2024 12:54:36 +0000 (UTC) Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by mail.notmuchmail.org (Postfix) with ESMTPS id 2EFE05E50F for ; Tue, 9 Jan 2024 12:54:34 +0000 (UTC) Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-a28d61ba65eso324709766b.3 for ; Tue, 09 Jan 2024 04:54:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704804873; x=1705409673; darn=notmuchmail.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=setvpTBb7WGtbp+umcHsKGxuQoOQzvh5y3epNNFBnyM=; b=bTv3qejunQNvWYddZIO5kocRbID+dpA3ZLCygDs3dS1prGQIDmqYLzr7CU38JRVTas XsasB5y6va8mTqhK1v/gE/kZffG4ckj0Kg0U6bN56e/rAPLhZHnUEjzB9HWc50NMwn3o RYK7siB+yNBshPPO32WURHaDfXbR40GvH978NWyAbYPWFtytja0CpSRUrb/xK6MBz8cj 4U++eR73Pt7g8DYXXe41j6BVPc4ULennjbUgUJ5KdpuZnhBqX4I9XyChDy4jtDDlxgs0 5QQpcNXVScgQ2gDRKuQwD9mychyDq4tvqyjNLDHv/5SMdi4BXUlkvXW7/1eIbYsYNXbN Jolw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704804873; x=1705409673; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=setvpTBb7WGtbp+umcHsKGxuQoOQzvh5y3epNNFBnyM=; b=hHnEPgoyvMw2dBWTTRtRVWVgZLjceXAW66gB4BvU0OgKdat5UDTuGDbSRjYJ5cqcYY +yWi6fnUi1wYE4cWvpcVr4qF24+CjuSs21KiQ7/Vyphq1KHvCWDxXS0ZqvPhJ1tnsOSs MPRQeqScOrUYaOU1NPF8g+KyRUK3UymykoOHu94C7fCD3aseUykdrwe2Hk39r3QibaMD ja5L8S5jXQHSpciEOl+G1I/FgXp65O6TELQI8mT7ohq6q85krLeQEed1qM5+y5WcT5DV OzFgsKMoxFmQdJ6spw52Zeq1Gmzl4o53XyoJscxn42N3XTrtlYn9yO9gs1so2gP9T6y6 2Reg== X-Gm-Message-State: AOJu0Yw4T7n6yNxU8XDi8NCT2dtQJ4OOSd+jgFI0TMn6QuLOeK6QjrDZ oJTBh8Ql6oeC3kcE/ndayxjZQYMUQ7EqMpTardIWBFq0N6I= X-Google-Smtp-Source: AGHT+IFyqGUXoAqhFQE/gK5CpbjZ8IaXT/HknjwyDBQJwI5F2HKAw3Iajjmi09VwlapBUdXUWz1qWIhIP0/7dYQiDkE= X-Received: by 2002:a17:906:d8d2:b0:a29:f6e2:2be2 with SMTP id re18-20020a170906d8d200b00a29f6e22be2mr204128ejb.148.1704804873267; Tue, 09 Jan 2024 04:54:33 -0800 (PST) MIME-Version: 1.0 References: <875y034e4a.fsf@tethera.net> <8734v64r7z.fsf@tethera.net> In-Reply-To: <8734v64r7z.fsf@tethera.net> From: Michael J Gruber Date: Tue, 9 Jan 2024 13:54:21 +0100 Message-ID: Subject: Re: BUG: Python's Message.header fails for empty headers To: David Bremner Message-ID-Hash: 5OFETO5NBBCHCNHNP3TJFI4IDM7JU63R X-Message-ID-Hash: 5OFETO5NBBCHCNHNP3TJFI4IDM7JU63R X-MailFrom: michaeljgruber@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: =?UTF-8?B?Vm9qdMSbY2ggS8OhbsSb?= , notmuch@notmuchmail.org X-Mailman-Version: 3.3.3 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-Country: DE X-Migadu-Queue-Id: 59100B930 X-Migadu-Scanner: mx10.migadu.com X-Migadu-Spam-Score: -1.63 X-Spam-Score: -1.63 X-TUID: vciNy8IZPFUL Am Di., 9. Jan. 2024 um 13:38 Uhr schrieb 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? I don't know. Missing vs. empty are two different cases. It may be that in terms of e-mail standards (RFC), a missing header is equivalent to an empty one. Then one can argue whether an empty header is a missing header (raise error) or a missing header is an empty header (return None) ... Or one may distinguish between mandatory headers and optional ones. I'd really check the RFC. In Python, there is a difference between a dictionary key with an empty value and a key which is not present, of course. So, if I think of the headers as a dictionary, I would expect to differentiate between those cases, unless the data which the dict represents (e-mail headers) treats them as equal by RFC. > > 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') That clarifies what OP observed :)