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).
This commit is contained in:
Lars Ingebrigtsen 2022-02-14 12:00:22 +01:00
parent 35bb4c1c3c
commit d52d913fa0
3 changed files with 10 additions and 2 deletions

View 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.

View 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,

View file

@ -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