[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#61847: debug-early-backtrace only works some of the time.
From: |
Stefan Monnier |
Subject: |
bug#61847: debug-early-backtrace only works some of the time. |
Date: |
Mon, 27 Feb 2023 14:15:22 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
> The cause of the problem was patch
>
> commit 08108a856a544a80d11b1e9e437fe6c45e25adec
> Author: Stefan Monnier <monnier@iro.umontreal.ca>
> Date: Fri Apr 29 22:18:09 2022 -0400
>
> debug-early: Print bytecode in a more manageable way
>
> * lisp/emacs-lisp/debug-early.el (debug-early-backtrace):
> Escape newlines to and bytecodes to make backtraces slightly more
> readable. Use `cl-prin1` when available.
>
> , which made debug-early.el dependent on arbitrarily nested Lisp code, in
> violation of its explicitly stated design goal to have _no_ dependence on
> Lisp code. Some of this Lisp simply fails to load.
Indeed (fboundp 'cl-prin1) was too optimistic a test since it just
checks whether we're before loading `loaddef.el` or after it, but
`cl-prin1` uses more (preloaded) features such as those provided by
`cl-generic` which is only loaded later.
> It's not clear why the patch was applied.
To get more readable backtraces when used after bootstrapping (as well as
in the later phases of bootstrapping).
> I propose fixing the bug by restoring the code to having no such
> dependencies with the following patch:
How 'bout the patch below instead.
Maybe we should instead try and check whether we're after the bootstrap
(not sure what would be the corresponding test).
Stefan
diff --git a/lisp/emacs-lisp/debug-early.el b/lisp/emacs-lisp/debug-early.el
index 395498f2206..65770a9c1d9 100644
--- a/lisp/emacs-lisp/debug-early.el
+++ b/lisp/emacs-lisp/debug-early.el
@@ -46,10 +46,13 @@ 'debug-early-backtrace
(print-escape-control-characters t)
(print-escape-nonascii t)
(prin1 (if (and (fboundp 'cl-prin1)
+ (fboundp 'cl-defmethod)
;; If we're being called while
;; bootstrapping, we won't be able to load
;; cl-print.
- (require 'cl-print nil t))
+ (condition-case nil
+ (require 'cl-print nil t)
+ (error nil)))
#'cl-prin1
#'prin1)))
(mapbacktrace