Subject: Re: bug#30489: 26.0.91; [PATCH] Data associated with json-readtable-error not a list

From: "Basil L. Contovounesios" <[email-masked]>
Date: Sun, 18 Mar 2018 14:23:30 +0000

>From bed6240056d6ca8f47c5709fbe7033c490c8738c Mon Sep 17 00:00:00 2001
From: "Basil L. Contovounesios" <[email-masked]>
Date: Fri, 16 Feb 2018 17:11:49 +0000
Subject: [PATCH] Pass json-readtable-error data as a list (bug#30489)

* lisp/json.el (json-readtable-dispatch): Fix error data.
* test/lisp/json-tests.el (test-json-read): Check error data is a
list.
---
 lisp/json.el            | 2 +-
 test/lisp/json-tests.el | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/lisp/json.el b/lisp/json.el
index b03a482ca6..d374f452e6 100644
--- a/lisp/json.el
+++ b/lisp/json.el
@@ -685,7 +685,7 @@ json-readtable-dispatch
       (push (list c 'json-read-number) table))
     (pcase-dolist (`(,c . ,rest) table)
       (push `((eq ,char ,c) (,@rest)) res))
-    `(cond ,@res (t (signal 'json-readtable-error ,char)))))
+    `(cond ,@res (t (signal 'json-readtable-error (list ,char))))))
 
 (defun json-read ()
   "Parse and return the JSON object following point.
diff --git a/test/lisp/json-tests.el b/test/lisp/json-tests.el
index 47f8047b34..ea562e8b13 100644
--- a/test/lisp/json-tests.el
+++ b/test/lisp/json-tests.el
@@ -309,7 +309,8 @@ json-tests--with-temp-buffer
   (json-tests--with-temp-buffer ""
     (should-error (json-read) :type 'json-end-of-file))
   (json-tests--with-temp-buffer "xxx"
-    (should-error (json-read) :type 'json-readtable-error)))
+    (let ((err (should-error (json-read) :type 'json-readtable-error)))
+      (should (equal (cdr err) '(?x))))))
 
 (ert-deftest test-json-read-from-string ()
   (let ((json-string "{ \"a\": 1 }"))
-- 
2.16.2

Noam Postavsky <[email-masked]> writes:

> Thanks, could you add a regression test for this too, please?  Since
> we've already had two mistakes independently generated, it seems likely
> we'll make more if this code is updated again.

Of course.  Is the attached up to scratch?

Thanks,

-- 
Basil