From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id AC13F6DE021A for ; Fri, 1 Feb 2019 05:45:37 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.005 X-Spam-Level: X-Spam-Status: No, score=-0.005 tagged_above=-999 required=5 tests=[AWL=-0.004, SPF_PASS=-0.001] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0B7e8E3QPMAs for ; Fri, 1 Feb 2019 05:45:37 -0800 (PST) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by arlo.cworth.org (Postfix) with ESMTPS id D9C7D6DE0207 for ; Fri, 1 Feb 2019 05:45:36 -0800 (PST) Received: from remotemail by fethera.tethera.net with local (Exim 4.89) (envelope-from ) id 1gpZ8Q-0006BX-98; Fri, 01 Feb 2019 08:45:34 -0500 Received: (nullmailer pid 20663 invoked by uid 1000); Fri, 01 Feb 2019 13:45:33 -0000 From: David Bremner To: Vincent A , notmuch@notmuchmail.org Subject: Re: [PATCH] python: fix get_property error when property doesn't exist In-Reply-To: References: Date: Fri, 01 Feb 2019 09:45:33 -0400 Message-ID: <877eejlj0i.fsf@tethera.net> MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Feb 2019 13:45:37 -0000 Vincent A writes: > In Python bindings, Message.get_property fails with an AttributeError > when trying to fetch a property that doesn't exist. > - return value.value.decode('utf-8') if value is not None else None > + if value is None or value.value is None: > + return None > + return value.value.decode('utf-8') > Should we be throwing an appropriate exception rather than returning None? That seems more pythonic to me. In either case we should document the error handling. d