emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master d52d913fa0: Don't signal errors in abbrev-table-p


From: Lars Ingebrigtsen
Subject: master d52d913fa0: Don't signal errors in abbrev-table-p
Date: Mon, 14 Feb 2022 06:01:35 -0500 (EST)

branch: master
commit d52d913fa032a6cd1b6422cbbd44169b318ca174
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Don't signal errors in abbrev-table-p
    
    * lisp/abbrev.el (abbrev-table-p): Ignore the error.
    * src/lread.c (oblookup): Signal `wrong-type-argument' instead of
    `error' if it turns out that we're not really in an obarray (bug#53988).
---
 lisp/abbrev.el            | 3 ++-
 src/lread.c               | 5 ++++-
 test/lisp/abbrev-tests.el | 4 ++++
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/lisp/abbrev.el b/lisp/abbrev.el
index 44328a2b28..214f7435d9 100644
--- a/lisp/abbrev.el
+++ b/lisp/abbrev.el
@@ -475,7 +475,8 @@ PROPS is a list of properties."
 (defun abbrev-table-p (object)
   "Return non-nil if OBJECT is an abbrev table."
   (and (obarrayp object)
-       (numberp (abbrev-table-get object :abbrev-table-modiff))))
+       (numberp (ignore-error 'wrong-type-argument
+                  (abbrev-table-get object :abbrev-table-modiff)))))
 
 (defun abbrev-table-empty-p (object &optional ignore-system)
   "Return nil if there are no abbrev symbols in OBJECT.
diff --git a/src/lread.c b/src/lread.c
index 502db1a8de..58b40ef37e 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -4626,7 +4626,9 @@ oblookup (Lisp_Object obarray, register const char *ptr, 
ptrdiff_t size, ptrdiff
   if (EQ (bucket, make_fixnum (0)))
     ;
   else if (!SYMBOLP (bucket))
-    error ("Bad data in guts of obarray"); /* Like CADR error message.  */
+    /* Like CADR error message.  */
+    xsignal2 (Qwrong_type_argument, Qobarrayp,
+             build_string ("Bad data in guts of obarray"));
   else
     for (tail = bucket; ; XSETSYMBOL (tail, XSYMBOL (tail)->u.s.next))
       {
@@ -5438,6 +5440,7 @@ This variable's value can only be set via file-local 
variables.
 See Info node `(elisp)Shorthands' for more details.  */);
   Vread_symbol_shorthands = Qnil;
   DEFSYM (Qobarray_cache, "obarray-cache");
+  DEFSYM (Qobarrayp, "obarrayp");
 
   DEFSYM (Qmacroexp__dynvars, "macroexp--dynvars");
   DEFVAR_LISP ("macroexp--dynvars", Vmacroexp__dynvars,
diff --git a/test/lisp/abbrev-tests.el b/test/lisp/abbrev-tests.el
index 394eae48ee..947178473e 100644
--- a/test/lisp/abbrev-tests.el
+++ b/test/lisp/abbrev-tests.el
@@ -301,6 +301,10 @@
         (inverse-add-abbrev table "Global" -1)))
     (should (string= (abbrev-expansion "text" table) "bar"))))
 
+(ert-deftest test-abbrev-table-p ()
+  (should-not (abbrev-table-p translation-table-vector))
+  (should (abbrev-table-p (make-abbrev-table))))
+
 (provide 'abbrev-tests)
 
 ;;; abbrev-tests.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]