From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id UH+yAAdhhmHdGwEAgWs5BA (envelope-from ) for ; Sat, 06 Nov 2021 12:03:35 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id SK4IOAZhhmFIGAAA1q6Kng (envelope-from ) for ; Sat, 06 Nov 2021 11:03:34 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [IPv6:2607:5300:201:3100::1657]) (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 91DF02D990 for ; Sat, 6 Nov 2021 12:03:34 +0100 (CET) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 7CCAB1FE7B; Sat, 6 Nov 2021 07:03:21 -0400 (EDT) Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by mail.notmuchmail.org (Postfix) with ESMTPS id EAE571FDC9 for ; Sat, 6 Nov 2021 07:03:17 -0400 (EDT) Received: by mail-wm1-x32f.google.com with SMTP id 71so9083341wma.4 for ; Sat, 06 Nov 2021 04:03:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RXttacD5vHoCl4VEoI5d4dYcKNVeOssiiO3XnY0cjdQ=; b=mnwiv7MjWSBl57SRduZ4Gt76sqt0l8AntFfUmmuj7fYmjoifFv2dLsXuwYFJQqeIjd G/JV840jluGW+fc9V4BS5g8BbkYRotMCdjqECAJciX/gaT4Uz6Z2t3uDDx21CvGmnpk2 VgxwSiluEcPXlj2hJwSmUddjqTl39zuaBQP26SDFuuhw7nALgoATxBzlha+VBK2rn/oX aXW+6soRgL3XaHua+2DsLuHk9VxQXFrzFXv2TkvUTNEQbF3mBkjumNV8hYZlApm9oNt4 2ZA5kCyuCbITxtDbBUJRWyGYool85mdOWVyRGS/bzvMWtiNRU/RCjQsxkF9nos84SJL0 yTiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=RXttacD5vHoCl4VEoI5d4dYcKNVeOssiiO3XnY0cjdQ=; b=OJ8u7wHYZanujfOK3xv+7HkxRhnFQmJKwyTM1u64yScsqcSMlE5EXkuxfKQZSeu/cB Z7bfaAPf9cFLXtBNIUozH29iWoKcSHXlzpKZHcu/w03pKsxTy3Ns3Ezl4zIc6arvnnJs qwe05UKCYRthtP8BW2RVvrKZBbjg4DNnXhwcH9BhPYMLt9awoPHH022l+WAxcA3gqEtI JzEhhJZ70cow9i+BfikEstCfyGFLXip8vk6Qr+TSsBZZ7iY/wrw8j+nQsw70ZMJXCA6W FU93uI9Bd6K4Q7kEhOF+k5dfikL3h2rndgReVBppx9T7pApfxV69LWbcWEkMHKN37qm9 5IMg== X-Gm-Message-State: AOAM533980vR4nC7lVF2WHE83Z78sBrqbiJEeFfqYpHUc+qx3iN8Nve2 CeypROcun2aKyQuQH5BA7ozFo2I8Gco= X-Google-Smtp-Source: ABdhPJwkttBqNNci8zu/zkvTFf/7sTmp8faDh5f9TffVSO/N32MBs9mL/s4Km3Yk13mLV5zAGmisXg== X-Received: by 2002:a1c:e912:: with SMTP id q18mr39114387wmc.121.1636196596370; Sat, 06 Nov 2021 04:03:16 -0700 (PDT) Received: from powell.devork.be (62-178-226-148.cable.dynamic.surfer.at. [62.178.226.148]) by smtp.gmail.com with ESMTPSA id n13sm10381364wrt.44.2021.11.06.04.03.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Nov 2021 04:03:16 -0700 (PDT) Sender: Floris Bruynooghe Received: (nullmailer pid 69794 invoked by uid 1000); Sat, 06 Nov 2021 11:03:15 -0000 From: Floris Bruynooghe To: notmuch@notmuchmail.org Subject: [PATCH] Fix error message when using notmuch_status_to_string Date: Sat, 6 Nov 2021 12:02:37 +0100 Message-Id: <20211106110236.69734-2-flub@devork.be> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211106110236.69734-1-flub@devork.be> References: <20211106110236.69734-1-flub@devork.be> MIME-Version: 1.0 Message-ID-Hash: RMHUSNN6IEQHLGWCRNNN6ORSYG7RYTF7 X-Message-ID-Hash: RMHUSNN6IEQHLGWCRNNN6ORSYG7RYTF7 X-MailFrom: floris.bruynooghe@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 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1636196614; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=gUGke6M6SwjTu1I0CK1QpeTQLhT8Pz4np4p02JiSf+c=; b=SxYJQ1Md1JcI6Wuw1/HtRpeNbN6yPigEVoP8BqPW2EBEGX6Jq+8qVbOvgeg4Tl0ei+XgkD k4spQLsfOZszSsER0LXhWwruVQ68BXLmcc5RpvRoGF69iZEE42f9aepK5YiPHsogFLlkGR /TZAOfZ9+BZi6pXfHBKRjVEcJBpOmyPaUxFUV5Z86Mj58VnvOkVVI2b9Vis6dMur4XFzr/ lS9f2PE8Zox5Zvx3sNAaCk9cp3nkR8ovsj/vNjxYoretXCNtFUKoAB61Z9qtEGHiPk5MFO HXAiv4AIL/upgPV2+9shJ6xgB4gwGDXMIucyzSiQUJX15uHB4RkKxY6+ThBBEQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1636196614; a=rsa-sha256; cv=none; b=fNZjmxT1RvbXBUOa80f81r1CcxxTwn8BM9s/VZgsExlL6iEIRUD1mZyrRlPmboWRDK/vJg mY6f5CiZC3zD6eHxynqaZnINKhZb6h0O/XmKpJbLUveU1roQMA9D3nYM4evu0I1j1FoUh3 MS8u/m4nZng+q/ItCdtDSZMy9K1qKrPgQ9JyP9sGIa8bubGUeSLFKyrgW14aLTYX/BMy/X XkJuFqnkR62qOqB23FTZWMwQ8a8ix/3GciJCIT79vBO+Y/xbepdfTXHU53QDywU5zwNwlV VTYdTMBlNIsWH/fRuq16kt3J9UIXBKPWG67D0z9AddmgPkk3DYW9MjR+u216qw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20210112 header.b=mnwiv7Mj; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -0.09 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20210112 header.b=mnwiv7Mj; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 91DF02D990 X-Spam-Score: -0.09 X-Migadu-Scanner: scn0.migadu.com X-TUID: +TICtkenZI0Z The python exception class was incorrectly loading the error message which resulted in unprintable exception objects. --- bindings/python-cffi/notmuch2/_errors.py | 3 ++- bindings/python-cffi/tests/test_errors.py | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 bindings/python-cffi/tests/test_errors.py diff --git a/bindings/python-cffi/notmuch2/_errors.py b/bindings/python-cffi/notmuch2/_errors.py index f55cc96b..17c3ad9c 100644 --- a/bindings/python-cffi/notmuch2/_errors.py +++ b/bindings/python-cffi/notmuch2/_errors.py @@ -83,7 +83,8 @@ class NotmuchError(Exception): if self.message: return self.message elif self.status: - return capi.lib.notmuch_status_to_string(self.status) + char_str = capi.lib.notmuch_status_to_string(self.status) + return capi.ffi.string(char_str).decode(errors='replace') else: return 'Unknown error' diff --git a/bindings/python-cffi/tests/test_errors.py b/bindings/python-cffi/tests/test_errors.py new file mode 100644 index 00000000..c2519f86 --- /dev/null +++ b/bindings/python-cffi/tests/test_errors.py @@ -0,0 +1,8 @@ +from notmuch2 import _capi as capi +from notmuch2 import _errors as errors + +def test_status_no_message(): + exc = errors.NotmuchError(capi.lib.NOTMUCH_STATUS_PATH_ERROR) + assert exc.status == capi.lib.NOTMUCH_STATUS_PATH_ERROR + assert exc.message is None + assert str(exc) == 'Path supplied is illegal for this function' -- 2.33.0