From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#24618: 26.0.50; `condition-case' doesn't allow catching all signals Date: Mon, 13 Aug 2018 22:38:17 -0400 Message-ID: <87va8dvfja.fsf@gmail.com> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1534214231 12776 195.159.176.226 (14 Aug 2018 02:37:11 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 14 Aug 2018 02:37:11 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) Cc: 24618@debbugs.gnu.org To: Philipp Stephani Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Aug 14 04:37:07 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fpPCk-0003B7-IH for geb-bug-gnu-emacs@m.gmane.org; Tue, 14 Aug 2018 04:37:06 +0200 Original-Received: from localhost ([::1]:42164 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fpPEp-0005xc-9r for geb-bug-gnu-emacs@m.gmane.org; Mon, 13 Aug 2018 22:39:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42038) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fpPEf-0005wK-R2 for bug-gnu-emacs@gnu.org; Mon, 13 Aug 2018 22:39:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fpPEc-0000bH-Nx for bug-gnu-emacs@gnu.org; Mon, 13 Aug 2018 22:39:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:45038) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fpPEc-0000b9-ES for bug-gnu-emacs@gnu.org; Mon, 13 Aug 2018 22:39:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fpPEc-0006jD-4D for bug-gnu-emacs@gnu.org; Mon, 13 Aug 2018 22:39:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 14 Aug 2018 02:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24618 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 24618-submit@debbugs.gnu.org id=B24618.153421430825803 (code B ref 24618); Tue, 14 Aug 2018 02:39:02 +0000 Original-Received: (at 24618) by debbugs.gnu.org; 14 Aug 2018 02:38:28 +0000 Original-Received: from localhost ([127.0.0.1]:50056 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fpPE3-0006i1-95 for submit@debbugs.gnu.org; Mon, 13 Aug 2018 22:38:27 -0400 Original-Received: from mail-it0-f41.google.com ([209.85.214.41]:52474) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fpPE1-0006hg-HW; Mon, 13 Aug 2018 22:38:25 -0400 Original-Received: by mail-it0-f41.google.com with SMTP id d9-v6so16246480itf.2; Mon, 13 Aug 2018 19:38:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=OyXqdWKNKO7JHdlym8kz+iXVEBN9FwlwKSSX5aZPXOA=; b=SQBTkrFMiBJukIBMntgbY97iZMIysBWfGK2OcFph6/7nJnUtEFv3XRLAmycm/NVdaQ 33s5+z0rojHa9hUK3g1y2dYCdUSqfLV6O140FADKrMYzw5l9KrWzL9jKikuld/P1ZvJa 3D95UxJyoeo/6jXVhgl65rRLt61iiI0qX99UKXIjQeT7GBuO3aiuN5CS2z5sFXGv1q6v uBcUJZ5whA0hbiQmdOMO7ptlavVqjx7PJGuPtiZH6lUnRHSJcUY3XJfwe2kringvFSea vgqzs2qq6Dbsg87g7FtZy1LR+0w2yeQ7ny2BsSv3rcigLmbtykEbduMaeT/Y/iDc7kkm Bf0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=OyXqdWKNKO7JHdlym8kz+iXVEBN9FwlwKSSX5aZPXOA=; b=IAl/vhBz7v/oM80cl6EkkDfUAUF5ew8vNK/blsJOK5wQiXGOhtnLpAo2M1/inSfL4k lgLdfj/X75kPSCxePJjSEuOU6k/Frp7of4IbMtr7prZICx48V0C0LHUupTMwB5Y8fp1/ e3Q2cX3B0WEOOnVzs/0Fjc2ByiwXe1G8Zn25aPJeofPiJNuoxip95WnZxMoFBhYQacJw gZpdX/32osgYSY/pVOxGPA4v0KTZs/sSW4o65v4JpqB+TjTzU8tHzvC2Rc0I2uHsndzS pMPZ5Pz0DXz/qdvR33g1In8TCIe7PBDUfk2IP4knPOP+AK9qmDwDmCpEvUIg0/2nrH8B XFHQ== X-Gm-Message-State: AOUpUlEP8PG8x7iONXyYhsb71mKrCAZnrwbz56VnyMqBUTxVEOvIwve9 QCmZM1DjtZ335HOASLaezWfl8vOq X-Google-Smtp-Source: AA+uWPzX9x21XF0ECswnVuzjKGQHNcdDhPc5t/vtGo211DAih22W+YmVrHBqY94hK+mw6sWrQrdlEQ== X-Received: by 2002:a02:1e41:: with SMTP id m62-v6mr17710026jad.110.1534214299863; Mon, 13 Aug 2018 19:38:19 -0700 (PDT) Original-Received: from zebian (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34]) by smtp.googlemail.com with ESMTPSA id i5-v6sm2333534ioq.5.2018.08.13.19.38.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 13 Aug 2018 19:38:18 -0700 (PDT) In-Reply-To: (Philipp Stephani's message of "Tue, 04 Oct 2016 18:42:27 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:149490 Archived-At: --=-=-= Content-Type: text/plain tags 24618 + patch quit Philipp Stephani writes: > Consider the following code: > > (condition-case err > (signal 'does-not-exist '(1 2)) > (error (print err))) > > The signal is not caught by condition-case because it has no error > conditions. This makes it impossible to reliably catch all signals > (without abusing the debugger). Yeah, I noticed this when I started looking at fixing ert to stop abusing the debugger like this (Bug#30745 and Bug#11218). > I propose that an error condition of 't' in `condition-case' should be > interpreted as 'all conditions'. Seems easy enough: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Allow-t-as-a-catch-all-condition-case-handler-Bug-24.patch Content-Description: patch >From a18b70875fbcf22009e64bc9d809d1575fba3429 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Thu, 9 Aug 2018 21:26:30 -0400 Subject: [PATCH] Allow t as a catch-all condition-case handler (Bug#24618) * src/eval.c (find_handler_clause): Accept a handler of t as always matching. (Fcondition_case): * doc/lispref/control.texi (Handling Errors): Document this. * etc/NEWS: Announce it. --- doc/lispref/control.texi | 7 ++++--- etc/NEWS | 3 +++ src/eval.c | 10 ++++++---- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/doc/lispref/control.texi b/doc/lispref/control.texi index 975ab3d075..8a6cf73af5 100644 --- a/doc/lispref/control.texi +++ b/doc/lispref/control.texi @@ -1878,9 +1878,10 @@ Handling Errors Each of the @var{handlers} is a list of the form @code{(@var{conditions} @var{body}@dots{})}. Here @var{conditions} is an error condition name to be handled, or a list of condition names (which can include @code{debug} -to allow the debugger to run before the handler); @var{body} is one or more -Lisp expressions to be executed when this handler handles an error. -Here are examples of handlers: +to allow the debugger to run before the handler). A condition name of +@code{t} matches any condition. @var{body} is one or more Lisp +expressions to be executed when this handler handles an error. Here +are examples of handlers: @example @group diff --git a/etc/NEWS b/etc/NEWS index 8abbd74e05..f7de6c7295 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -836,6 +836,9 @@ specially; they are now allocated like any other pseudovector. * Lisp Changes in Emacs 27.1 +++ +** 'condition-case' now accepts 't' to match any error symbol. + ++++ ** New function 'proper-list-p'. Given a proper list as argument, this predicate returns its length; otherwise, it returns nil. 'format-proper-list-p' is now an obsolete diff --git a/src/eval.c b/src/eval.c index 8745ba9ef9..8700f0e202 100644 --- a/src/eval.c +++ b/src/eval.c @@ -1215,9 +1215,9 @@ DEFUN ("condition-case", Fcondition_case, Scondition_case, 2, UNEVALLED, 0, Each element of HANDLERS looks like (CONDITION-NAME BODY...) where the BODY is made of Lisp expressions. -A handler is applicable to an error -if CONDITION-NAME is one of the error's condition names. -If an error happens, the first applicable handler is run. +A handler is applicable to an error if CONDITION-NAME is one of the +error's condition names. A CONDITION-NAME of t applies to any error +symbol. If an error happens, the first applicable handler is run. The car of a handler may be a list of condition names instead of a single condition name; then it handles all of them. If the special @@ -1854,7 +1854,9 @@ find_handler_clause (Lisp_Object handlers, Lisp_Object conditions) for (h = handlers; CONSP (h); h = XCDR (h)) { Lisp_Object handler = XCAR (h); - if (!NILP (Fmemq (handler, conditions))) + if (!NILP (Fmemq (handler, conditions)) + /* t is also used as a catch-all by Lisp code. */ + || EQ (handler, Qt)) return handlers; } -- 2.11.0 --=-=-=--