From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Basil Contovounesios via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#64404: 30.0.50; condition-case-unless-debug mishandles :success Date: Mon, 03 Jul 2023 12:10:20 +0100 Message-ID: <87y1jxntcz.fsf@epfl.ch> References: <87sfa7bf7p.fsf@epfl.ch> <88ACE707-A181-4D76-9773-A1B772C28CC1@gmail.com> <87r0pp8i17.fsf@epfl.ch> <7FC074F2-864E-43DA-B05C-22DD8678EAE5@gmail.com> Reply-To: Basil 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="31088"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Eli Zaretskii , 64404@debbugs.gnu.org, Stefan Monnier To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jul 03 13:11:33 2023 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 1qGHSu-0007t6-Tv for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 03 Jul 2023 13:11:33 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGHSX-0005SW-BG; Mon, 03 Jul 2023 07:11:09 -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 1qGHSQ-0005S1-S7 for bug-gnu-emacs@gnu.org; Mon, 03 Jul 2023 07:11:03 -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 1qGHSQ-0006mq-JD for bug-gnu-emacs@gnu.org; Mon, 03 Jul 2023 07:11:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qGHSP-0003Rp-Vj for bug-gnu-emacs@gnu.org; Mon, 03 Jul 2023 07:11:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Basil Contovounesios Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 03 Jul 2023 11:11:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64404 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 64404-submit@debbugs.gnu.org id=B64404.168838263513218 (code B ref 64404); Mon, 03 Jul 2023 11:11:01 +0000 Original-Received: (at 64404) by debbugs.gnu.org; 3 Jul 2023 11:10:35 +0000 Original-Received: from localhost ([127.0.0.1]:33243 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qGHRy-0003R7-JX for submit@debbugs.gnu.org; Mon, 03 Jul 2023 07:10:35 -0400 Original-Received: from mail-wr1-f44.google.com ([209.85.221.44]:50619) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qGHRs-0003Qo-DN for 64404@debbugs.gnu.org; Mon, 03 Jul 2023 07:10:32 -0400 Original-Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-314313f127fso1763837f8f.1 for <64404@debbugs.gnu.org>; Mon, 03 Jul 2023 04:10:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd.ie; s=google21; t=1688382622; x=1690974622; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=Ivk9j4C9+FYiRXKgKm8MzOnn7z4mUKt1VYlQcej3tEk=; b=DqIZaDWBnF0BAEOnReF+NQmvTFAuH46YCvMYSZEUhmTbEoW1VCVFz8wo71X8bYAi9d b5CXYCpPTP4i96EonbNo4fLb9fXxpE+fwWpIh4fD1DdJi22N8OCECscxDMmWCTfg5GOv d5ZjYoa4M8mxgX9jhPffaXZvrCe1+MZrs1vS0jXZ1Q2GtUScT9EWz3ACrv0X/nD9B2o2 lbYhD1bsCuOqDpatYQiXL4KYAnXOD4jhR7KkttDCCEPD8HnSE8Sp+2foxjamMPIQnWMh rL1hNkzCCxxr+/3Wc140fvq5cvuqkWhF5s/s7MaYgFYk1SJIGE6wpkM6RDc6RGDcwg78 XsmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688382622; x=1690974622; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Ivk9j4C9+FYiRXKgKm8MzOnn7z4mUKt1VYlQcej3tEk=; b=GsNowHnuMrgW7u+2/BWMT5oCZLaY0KBC6RinPPfAaC5Qk/BD64bVOwuq68x+8OD0Ka FSAneAFwsdoyyIVv+G+f3AhMNbyJFjbPt3aE2Te2Kp10nVRlyZj/UKfLeF+UI+1kMBoF BMDLpCSU4+/3jg15ntaNL3nm4pTgverrG40jYYT9GdxixoKbr3d4cUxDj/iw8jec8R+h GN5gEPtXr+fzWUgiB8NB+ElHypzzCj7xhjh8Gsg6V+Y2Th68ocHBzIKK4kbnS1lbc/4t /SRFRAVM0Q0IqI9BdeOkFfyqdT9rufvioGpGoUEIWxRobOb57Oi79+sVJJGGshGzGNm/ HwaA== X-Gm-Message-State: ABy/qLZi5y/s2EuYY7ZKg4wLzG9yHdkbLUcrAbJfqSqwYlu0FONfeail cnCyk/RbnlWV0kS44XtXimuAjg== X-Google-Smtp-Source: APBJJlF8r51T8PlhYnDTxSLsgmh3EEg+gZu90PM/r+k+o3IFTUu03hr92eWAhhC9aPwqf7lxYJPITQ== X-Received: by 2002:a5d:490a:0:b0:314:ff1:e714 with SMTP id x10-20020a5d490a000000b003140ff1e714mr8901289wrq.5.1688382622313; Mon, 03 Jul 2023 04:10:22 -0700 (PDT) Original-Received: from localhost ([217.173.96.166]) by smtp.gmail.com with ESMTPSA id m16-20020a5d6250000000b003068f5cca8csm25182101wrv.94.2023.07.03.04.10.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 04:10:21 -0700 (PDT) In-Reply-To: <7FC074F2-864E-43DA-B05C-22DD8678EAE5@gmail.com> ("Mattias =?UTF-8?Q?Engdeg=C3=A5rd?="'s message of "Mon, 3 Jul 2023 12:09:43 +0200") 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:264516 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mattias Engdeg=C3=A5rd [2023-07-03 12:09 +0200] wrote: > That looks fine! Just throw in a test case for condition-case-unless-debu= g (with > and without :success) that actually catches an error, to make sure that t= he > change hasn't impaired the basic functionality. Right, how's this: --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Fix-condition-case-unless-debug-with-success.patch >From 6e74cd34dad6696c0be726fc48ee7fcc9ccf7f4f Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" Date: Mon, 3 Jul 2023 10:10:47 +0100 Subject: [PATCH] Fix condition-case-unless-debug with :success * lisp/subr.el (condition-case-unless-debug): Don't add debug condition to :success handler (bug#64404). * test/lisp/subr-tests.el (condition-case-unless-debug) (condition-case-unless-debug-success): New tests. --- lisp/subr.el | 9 ++++++--- test/lisp/subr-tests.el | 31 +++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/lisp/subr.el b/lisp/subr.el index 4c462830120..483083b29c3 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -4987,9 +4987,12 @@ condition-case-unless-debug `(condition-case ,var ,bodyform ,@(mapcar (lambda (handler) - `((debug ,@(if (listp (car handler)) (car handler) - (list (car handler)))) - ,@(cdr handler))) + (let ((condition (car handler))) + (if (eq condition :success) + handler + `((debug ,@(if (listp condition) condition + (list condition))) + ,@(cdr handler))))) handlers))) (defmacro with-demoted-errors (format &rest body) diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el index 1c220b1da18..0d409cead26 100644 --- a/test/lisp/subr-tests.el +++ b/test/lisp/subr-tests.el @@ -1256,5 +1256,36 @@ subr--copy-tree "((a b) (a b) #2# #2# #3# #3#)" "((a b) (a b) [c d] [c d] #s(e f) #s(e f))"))))))) +(ert-deftest condition-case-unless-debug () + "Test `condition-case-unless-debug'." + (let ((debug-on-error nil)) + (with-suppressed-warnings ((suspicious condition-case)) + (should (= 0 (condition-case-unless-debug nil 0)))) + (should (= 0 (condition-case-unless-debug nil 0 (t 1)))) + (should (= 0 (condition-case-unless-debug x 0 (t (1+ x))))) + (should (= 1 (condition-case-unless-debug nil (error "") (t 1)))) + (should (equal (condition-case-unless-debug x (error "") (t x)) + '(error ""))))) + +(ert-deftest condition-case-unless-debug-success () + "Test `condition-case-unless-debug' with :success (bug#64404)." + (let ((debug-on-error nil)) + (should (= 1 (condition-case-unless-debug nil 0 (:success 1)))) + (should (= 1 (condition-case-unless-debug nil 0 (:success 1) (t 2)))) + (should (= 1 (condition-case-unless-debug nil 0 (t 2) (:success 1)))) + (should (= 1 (condition-case-unless-debug x 0 (:success (1+ x))))) + (should (= 1 (condition-case-unless-debug x 0 (:success (1+ x)) (t x)))) + (should (= 1 (condition-case-unless-debug x 0 (t x) (:success (1+ x))))) + (should (= 2 (condition-case-unless-debug nil (error "") + (:success 1) (t 2)))) + (should (= 2 (condition-case-unless-debug nil (error "") + (t 2) (:success 1)))) + (should (equal (condition-case-unless-debug x (error "") + (:success (1+ x)) (t x)) + '(error ""))) + (should (equal (condition-case-unless-debug x (error "") + (t x) (:success (1+ x))) + '(error ""))))) + (provide 'subr-tests) ;;; subr-tests.el ends here -- 2.34.1 --=-=-= Content-Type: text/plain Thanks, -- Basil --=-=-=--