GNU bug report logs -
#24618
26.0.50; `condition-case' doesn't allow catching all signals
Previous Next
Reported by: Philipp Stephani <p.stephani2 <at> gmail.com>
Date: Tue, 4 Oct 2016 16:43:01 UTC
Severity: wishlist
Tags: fixed, patch
Found in version 26.0.50
Fixed in version 27.1
Done: Noam Postavsky <npostavs <at> gmail.com>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 24618 in the body.
You can then email your comments to 24618 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#24618
; Package
emacs
.
(Tue, 04 Oct 2016 16:43:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Philipp Stephani <p.stephani2 <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Tue, 04 Oct 2016 16:43:01 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
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). I propose that an error condition of
't' in `condition-case' should be interpreted as 'all conditions'.
In GNU Emacs 26.0.50.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.10.8)
of 2016-10-04 built on unknown
Repository revision: e2913dc880b9843bf69cf885270551bafeb46120
Windowing system distributor 'The X.Org Foundation', version 11.0.11501000
System Description: Ubuntu 14.04 LTS
Recent messages:
mwheel-scroll: Beginning of buffer [7 times]
Mark set
Sending...
Mark set [2 times]
Sending via mail...
Setting ‘smtpmail-smtp-server’ temporarily since "emacs -q" would overwrite customizations
Setting ‘smtpmail-smtp-service’ temporarily since "emacs -q" would overwrite customizations
Sending email
Sending email done
Sending...done
Configured using:
'configure --with-modules --enable-checking
--enable-check-lisp-object-type'
Configured features:
XPM JPEG TIFF GIF PNG SOUND GSETTINGS NOTIFY GNUTLS FREETYPE XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 MODULES
Important settings:
value of $LANG: en_US.UTF-8
locale-coding-system: utf-8-unix
Major mode: Lisp Interaction
Minor modes in effect:
tooltip-mode: t
global-eldoc-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
tool-bar-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
line-number-mode: t
transient-mark-mode: t
Load-path shadows:
None found.
Features:
(network-stream nsm starttls tls gnutls mailalias smtpmail auth-source
cl-seq eieio eieio-core cl-macs eieio-loaddefs qp cus-edit cus-start
cus-load wid-edit pp shadow sort mail-extr emacsbug message subr-x puny
seq byte-opt gv bytecomp byte-compile cl-extra help-mode cconv
cl-loaddefs pcase cl-lib dired dired-loaddefs format-spec rfc822 mml
easymenu mml-sec password-cache epa derived epg epg-config gnus-util
rmail rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils time-date mule-util tooltip eldoc electric
uniquify ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list newcomment elisp-mode lisp-mode prog-mode register page
menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core term/tty-colors frame cl-generic cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese charscript case-table epa-hook
jka-cmpr-hook help simple abbrev obarray minibuffer cl-preloaded nadvice
loaddefs button faces cus-face macroexp files text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote inotify dynamic-setting
system-font-setting font-render-setting move-toolbar gtk x-toolkit x
multi-tty make-network-process emacs)
Memory information:
((conses 16 126071 14602)
(symbols 48 22713 6)
(miscs 40 341 241)
(strings 32 23705 8690)
(string-bytes 1 748309)
(vectors 16 22599)
(vector-slots 8 1236864 203799)
(floats 8 222 372)
(intervals 56 534 27)
(buffers 976 15)
(heap 1024 59649 5444))
--
Google Germany GmbH
Erika-Mann-Straße 33
80636 München
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Geschäftsführer: Matthew Scott Sucherman, Paul Terence Manicle
Diese E-Mail ist vertraulich. Wenn Sie nicht der richtige Adressat sind,
leiten Sie diese bitte nicht weiter, informieren Sie den Absender und löschen
Sie die E-Mail und alle Anhänge. Vielen Dank.
This e-mail is confidential. If you are not the right addressee please do not
forward it, please inform the sender, and please erase this e-mail including
any attachments. Thanks.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#24618
; Package
emacs
.
(Tue, 14 Aug 2018 02:39:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 24618 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
tags 24618 + patch
quit
Philipp Stephani <p.stephani2 <at> gmail.com> 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:
[0001-Allow-t-as-a-catch-all-condition-case-handler-Bug-24.patch (text/x-diff, inline)]
From a18b70875fbcf22009e64bc9d809d1575fba3429 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs <at> gmail.com>
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
Added tag(s) patch.
Request was from
Noam Postavsky <npostavs <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Tue, 14 Aug 2018 02:39:02 GMT)
Full text and
rfc822 format available.
Added indication that bug 24618 blocks30745
Request was from
Noam Postavsky <npostavs <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Wed, 15 Aug 2018 00:48:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#24618
; Package
emacs
.
(Tue, 04 Sep 2018 23:07:02 GMT)
Full text and
rfc822 format available.
Message #15 received at 24618 <at> debbugs.gnu.org (full text, mbox):
tags 24618 fixed
close 24618 27.1
quit
Philipp Stephani <p.stephani2 <at> gmail.com> 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). I propose that an error condition of
> 't' in `condition-case' should be interpreted as 'all conditions'.
Done in master.
[1: 425c281164]: 2018-09-04 18:50:15 -0400
Allow t as a catch-all condition-case handler (Bug#24618)
https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=425c2811641a6b8ec4549cad5f6bd15a46bc95d5
Added tag(s) fixed.
Request was from
Noam Postavsky <npostavs <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Tue, 04 Sep 2018 23:07:02 GMT)
Full text and
rfc822 format available.
bug marked as fixed in version 27.1, send any further explanations to
24618 <at> debbugs.gnu.org and Philipp Stephani <p.stephani2 <at> gmail.com>
Request was from
Noam Postavsky <npostavs <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Tue, 04 Sep 2018 23:07:02 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Wed, 03 Oct 2018 11:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 6 years and 339 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.