]> git.eshelyaron.com Git - emacs.git/commitdiff
Don't signal errors in abbrev-table-p
authorLars Ingebrigtsen <larsi@gnus.org>
Mon, 14 Feb 2022 11:00:22 +0000 (12:00 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Mon, 14 Feb 2022 11:00:22 +0000 (12:00 +0100)
* 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
src/lread.c
test/lisp/abbrev-tests.el

index 44328a2b2839c41cb464c039ef4c10b2da9e3673..214f7435d91f05fae51e65591784187102b609ae 100644 (file)
@@ -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.
index 502db1a8de5867d174c3383b49743d88b783dee4..58b40ef37e3bbc41a334e6e9d5dd614c6b8b7c93 100644 (file)
@@ -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,
index 394eae48ee3ffb126053191db6b096e02f293df4..947178473e4ec96a0c4e3ced33cf678f89f48a68 100644 (file)
         (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