From d52d913fa032a6cd1b6422cbbd44169b318ca174 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Mon, 14 Feb 2022 12:00:22 +0100 Subject: [PATCH] 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 44328a2b283..214f7435d91 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 502db1a8de5..58b40ef37e3 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 394eae48ee3..947178473e4 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 -- 2.39.5