Subject: Re: bug#6991: Please keep bytecode out of *Backtrace* buffers

From: [email-masked]
Date: Fri, 18 Nov 2016 20:55:54 -0500

It looks like this bug was closed a couple times because
[email-masked] was added to the Cc list.  I've removed it,
and let's try not to add it again.

Drew Adams <[email-masked]> writes:
>
> Here's a backtrace with some byte-code in it:
>
> Debugger entered--entering a function:
> * icicle-ucs-names()
> * #[(prompt &optional names) "\204
>
>
> See, only the top two lines got pasted (even into an Outlook
> window, and the second line was truncated at the first null
> byte (it appears as ^@ in the backtrace, where that is a null
> char and not two chars).

I would propose something like the below, which will cause the NUL byte
to be rendered as \0 instead of ^@.  We could potentially do this with
other control characters too, if they cause trouble too?

I do think it's worth keeping the bytecode in the backtrace, because
it's not useless: you can run `disassemble' on it and get something
meaningful.  Perhaps hiding the byte code with display properties would
be useful.

modified   src/print.c
@@ -1477,18 +1477,20 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
 		     could be taken as part of it,
 		     output `\ ' to prevent that.  */
 		  if (need_nonhex && c_isxdigit (c))
 		    print_c_string ("\\ ", printcharfun);
+                  need_nonhex = false;
 
 		  if (c == '\n' && print_escape_newlines
 		      ? (c = 'n', true)
 		      : c == '\f' && print_escape_newlines
 		      ? (c = 'f', true)
+                      : c == '\0' && print_escape_nonascii
+                      ? (c = '0', need_nonhex = true)
 		      : c == '\"' || c == '\\')
 		    printchar ('\\', printcharfun);
 
 		  printchar (c, printcharfun);
-		  need_nonhex = false;
 		}
 	    }
 	  printchar ('\"', printcharfun);