From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Basil L. Contovounesios" via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#58720: 29.0.50; Improve error reporting of EUDC plist functions Date: Sat, 22 Oct 2022 20:39:46 +0300 Message-ID: <8735bfpxjx.fsf@tcd.ie> Reply-To: "Basil L. Contovounesios" Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36493"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Thomas Fitzsimmons To: 58720@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Oct 24 04:29:33 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1omnDY-0009Gb-Rg for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 24 Oct 2022 04:29:33 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1omihE-0005Pi-US for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 23 Oct 2022 17:39:52 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1omITc-00022d-8W for bug-gnu-emacs@gnu.org; Sat, 22 Oct 2022 13:40:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1omITa-0005Jm-Bm for bug-gnu-emacs@gnu.org; Sat, 22 Oct 2022 13:40:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1omITZ-0007G3-Pe; Sat, 22 Oct 2022 13:40:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Basil L. Contovounesios" Original-Sender: "Debbugs-submit" Resent-CC: fitzsim@fitzsim.org, bug-gnu-emacs@gnu.org Resent-Date: Sat, 22 Oct 2022 17:40:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 58720 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org X-Debbugs-Original-Xcc: Thomas Fitzsimmons Original-Received: via spool by submit@debbugs.gnu.org id=B.166646040027886 (code B ref -1); Sat, 22 Oct 2022 17:40:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 22 Oct 2022 17:40:00 +0000 Original-Received: from localhost ([127.0.0.1]:42273 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1omITY-0007Fi-6X for submit@debbugs.gnu.org; Sat, 22 Oct 2022 13:40:00 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:58500) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1omITV-0007FY-1J for submit@debbugs.gnu.org; Sat, 22 Oct 2022 13:39:58 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1omITU-00022E-N6 for bug-gnu-emacs@gnu.org; Sat, 22 Oct 2022 13:39:56 -0400 Original-Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1omITS-0005IH-11 for bug-gnu-emacs@gnu.org; Sat, 22 Oct 2022 13:39:56 -0400 Original-Received: by mail-ed1-x52b.google.com with SMTP id e18so16982681edj.3 for ; Sat, 22 Oct 2022 10:39:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd.ie; s=google21; h=mime-version:message-id:date:subject:to:from:from:to:cc:subject :date:message-id:reply-to; bh=tatiUO62JBVWPSuAagz35bboaB3jHip9fCPV8M87ODU=; b=GSS4mMrt7NVb8C6Gpd9ZfiBSb8zUodH1BIeWXJw5XhiMu94w930Ya4DPP9V3A300Nt FHoJXI4yYk7wZkQxUCHtVlHGqbZKgNlskRQaSVpMpze65bRWolIrf5+5izEDLg9itcvK 5KvpN5KTYH/iMWCP2FR9X3JFSHTWJzLF+/8fujd3TTwDhOo+kzbm/Rjvul1PJJVPbAk8 0eMeMtkasatLa+7+lKqcmb8YfMxCrtEvVFnblJ6fFFLN63mwBNM+nlB9AqBwPa8NLZ+u PNJadXYvgStDHDNIaD9E//fk/MXDAc4528Gw4QK+L2yfTerZO4uzwcTNWPFavNa5Lj2c 2ZVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:subject:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=tatiUO62JBVWPSuAagz35bboaB3jHip9fCPV8M87ODU=; b=KkOzvKENvnkS9AiNrn6Iz+8WUGWyrTzY4w4FpGxYcuLeq0iIBd0oQ6LBYsf2lm7ZiN JoHEGDJ4px0Okm5ORysqKtOHNIjbLRge8Is3VW7+BFP82gsYPq7t9kBGX3WGPOV0JWao ifkjJngj5Re3CLn/amj6ChHBunUTfZvoijt4rcHJZy5zYLlwd2Ei6L/kSBfJwb2YXJxX tUBjAM3qRsEPvziFIEqbJA0ss+BNcb0KfMeAKp9Ef4auFb15bJAH7wqot1yw0z+Jq22m Xnu+OWzLjcRNo2dzQyisRT3GfXtf1qxZFUnMEjnYQGczl+QtqHLq3MnY0ewjd7ZGSI6v VndQ== X-Gm-Message-State: ACrzQf3dP+TMIqGOvfL4QK/wH4HNyBpwFJULcgfmNyccrbWJopzlxhSf rupTNHWb+p1YZFHgAHnCjUJ6rGEaC1pJ2w== X-Google-Smtp-Source: AMsMyM4TTYCvLiwxumR2Z9OMD3+y/gHle0vHj1sI5EPh7EUhRPW2IA8ztwW815A1zreZ5uBxW8GCzg== X-Received: by 2002:a17:907:2bf6:b0:7a3:6230:dc53 with SMTP id gv54-20020a1709072bf600b007a36230dc53mr1255680ejc.82.1666460389250; Sat, 22 Oct 2022 10:39:49 -0700 (PDT) Original-Received: from localhost ([2a02:587:321f:7e8a:d9:365a:ced1:b3d1]) by smtp.gmail.com with ESMTPSA id p10-20020a170906228a00b0078bfe57fc7bsm13011040eja.47.2022.10.22.10.39.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Oct 2022 10:39:48 -0700 (PDT) Received-SPF: pass client-ip=2a00:1450:4864:20::52b; envelope-from=contovob@tcd.ie; helo=mail-ed1-x52b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:246053 Archived-At: --=-=-= Content-Type: text/plain Severity: wishlist Tags: patch In https://bugs.gnu.org/58531#19 it was suggested that eudc-plist-member, eudc-plist-get, and eudc-lax-plist-get could signal a more informative wrong-type-argument instead of a generic static error when passed a degenerate plist argument. The attached patch makes this so. An alternative is to simply call plist-member and plist-get directly, relying on them for any error reporting, and not worry about arguments that degenerate further down the list than the point of interest. WDYT? How important is it to name and shame degenerate plists as eagerly as possible in EUDC? Thanks, -- Basil --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Improve-error-reporting-of-EUDC-plist-functions.patch >From e9e447214b2b0d19af8b7dc43abbcd4c7944a065 Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" Date: Sat, 22 Oct 2022 20:25:54 +0300 Subject: [PATCH] Improve error reporting of EUDC plist functions * lisp/net/eudc.el (eudc--plist-member): Signal a more informative wrong-type-argument instead of a generic error (bug#58531#19). * test/lisp/net/eudc-tests.el (eudc--plist-member) (eudc-plist-member, eudc-plist-get, eudc-lax-plist-get): Update tests accordingly. --- lisp/net/eudc.el | 5 ++--- test/lisp/net/eudc-tests.el | 24 ++++++++++++------------ 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/lisp/net/eudc.el b/lisp/net/eudc.el index 0283b04574..5f9e78fc7f 100644 --- a/lisp/net/eudc.el +++ b/lisp/net/eudc.el @@ -108,9 +108,8 @@ eudc--using-bbdb-3-or-newer-p (defun eudc--plist-member (plist prop &optional predicate) "Like `plist-member', but signal on invalid PLIST." - ;; Could also use `plistp', but that would change the error. - (or (zerop (% (length plist) 2)) - (error "Malformed plist")) + (or (plistp plist) + (signal 'wrong-type-argument `(plistp ,plist))) (plist-member plist prop predicate)) (defun eudc-plist-member (plist prop) diff --git a/test/lisp/net/eudc-tests.el b/test/lisp/net/eudc-tests.el index 219c250bf0..915006a97c 100644 --- a/test/lisp/net/eudc-tests.el +++ b/test/lisp/net/eudc-tests.el @@ -26,9 +26,9 @@ eudc--plist-member (dolist (obj '(a (a . a) (a a . a))) (should-error (eudc--plist-member obj nil) :type 'wrong-type-argument)) (dolist (plist '((nil) (a) (a a a))) - (dolist (key '(nil a)) - (should (equal (should-error (eudc--plist-member plist key)) - '(error "Malformed plist"))))) + (let ((err `(wrong-type-argument plistp ,(copy-sequence plist)))) + (dolist (key '(nil a)) + (should (equal err (should-error (eudc--plist-member plist key))))))) (let ((-nil (string ?n ?i ?l)) (-a (string ?a))) (should-not (eudc--plist-member () nil)) @@ -56,9 +56,9 @@ eudc-plist-member (dolist (obj '(a (a . a) (a a . a))) (should-error (eudc-plist-member obj nil) :type 'wrong-type-argument)) (dolist (plist '((nil) (a) (a a a))) - (dolist (key '(nil a)) - (should (equal (should-error (eudc-plist-member plist key)) - '(error "Malformed plist"))))) + (let ((err `(wrong-type-argument plistp ,(copy-sequence plist)))) + (dolist (key '(nil a)) + (should (equal err (should-error (eudc-plist-member plist key))))))) (let ((-nil (string ?n ?i ?l)) (-a (string ?a))) (should-not (eudc-plist-member () nil)) @@ -86,9 +86,9 @@ eudc-plist-get (dolist (obj '(a (a . a) (a a . a))) (should-error (eudc-plist-get obj nil) :type 'wrong-type-argument)) (dolist (plist '((nil) (a) (a a a))) - (dolist (key '(nil a)) - (should (equal (should-error (eudc-plist-get plist key)) - '(error "Malformed plist"))))) + (let ((err `(wrong-type-argument plistp ,(copy-sequence plist)))) + (dolist (key '(nil a)) + (should (equal err (should-error (eudc-plist-get plist key))))))) (let ((-nil (string ?n ?i ?l)) (-a (string ?a))) (should-not (eudc-plist-get () nil)) @@ -120,9 +120,9 @@ eudc-lax-plist-get (dolist (obj '(a (a . a) (a a . a))) (should-error (eudc-lax-plist-get obj nil) :type 'wrong-type-argument)) (dolist (plist '((nil) (a) (a a a))) - (dolist (key '(nil a)) - (should (equal (should-error (eudc-lax-plist-get plist key)) - '(error "Malformed plist"))))) + (let ((err `(wrong-type-argument plistp ,(copy-sequence plist)))) + (dolist (key '(nil a)) + (should (equal err (should-error (eudc-lax-plist-get plist key))))))) (let ((-nil (string ?n ?i ?l)) (-a (string ?a))) (should-not (eudc-lax-plist-get () nil)) -- 2.35.1 --=-=-=--