GNU bug report logs - #29220
26.0.90; eieio-persistent-read fail to restore saved object.

Previous Next

Package: emacs;

Reported by: pierre.techoueyres <at> free.fr (Pierre Téchoueyres)

Date: Wed, 8 Nov 2017 22:20:01 UTC

Severity: normal

Merged with 33441

Found in version 26.0.90

Full log


View this message in rfc822 format

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Eric Abrahamsen <eric <at> ericabrahamsen.net>
Cc: 29220 <at> debbugs.gnu.org, Noam Postavsky <npostavs <at> users.sourceforge.net>, Pierre Téchoueyres <pierre.techoueyres <at> free.fr>
Subject: bug#29220: 26.0.90; eieio-persistent-read fail to restore saved object.
Date: Mon, 04 Dec 2017 21:08:40 -0500
> --- a/lisp/emacs-lisp/eieio-base.el
> +++ b/lisp/emacs-lisp/eieio-base.el
> @@ -354,15 +354,34 @@ eieio-persistent-validate/fix-slot-value
>  		   proposed-value))
>  		 (t
>  		  proposed-value))))
> +	((stringp proposed-value)
> +	 ;; Remove string properties.
> +	 (substring-no-properties proposed-value))
> +
> +        ;; For hash-tables and vectors, the top-level `read' will not
> +        ;; "look inside" member values, so we need to do that
> +        ;; explicitly.
> +        ((hash-table-p proposed-value)
> +         (maphash
> +          (lambda (key value)
> +            (when (class-p (car-safe value))
> +              (setf (gethash key proposed-value)
> +                    (eieio-persistent-convert-list-to-object
> +                     value))))
> +          proposed-value)
> +         proposed-value)
> +
> +        ((vectorp proposed-value)
> +         (dotimes (i (length proposed-value))
> +           (when (class-p (car-safe (aref proposed-value i)))
> +             (aset proposed-value i
> +                   (eieio-persistent-convert-list-to-object
> +                    (aref proposed-value i)))))
> +         proposed-value)
 
> -	 ((stringp proposed-value)
> -	  ;; Else, check for strings, remove properties.
> -	  (substring-no-properties proposed-value))
> -
> -	 (t
> -	  ;; Else, just return whatever the constant was.
> -	  proposed-value))
> -  )
> +	(t
> +	 ;; Else, just return whatever the constant was.
> +	 proposed-value)))

Not sure why the `stringp` part was reindented, and an empty line was
lost (which de-synchronized the diff), but other than that, it looks fine.

> +	((hash-table-p thing)
> +	 (maphash
> +	  (lambda (key val)
> +	    (setf (gethash key thing)
> +		  (read
> +		   (with-output-to-string
> +		     (temp-eieio-override-prin1 val)))))
> +	  thing)
> +	 (prin1 thing))
> +	((vectorp thing)
> +	 (dotimes (i (length thing))
> +	   (aset thing i
> +		 (read
> +		  (with-output-to-string
> +		    (temp-eieio-override-prin1
> +		     (aref thing i))))))
> +	 (prin1 thing))

This looks wrong, OTOH:
- temp-eieio-override-prin1 does not exist in my copy of Emacs `master`.
- you modify the object you received, so while the print part will
  presumably work OK, the object left after that is unusable.

Maybe a better option is to print something of the form

   (vector <exp1> <exp2> ...)

i.e. not something that looks like a vector.  Or otherwise, print the
"standard" syntax of a vector/hash-table, but do it by hand rather than
rely on prin1 to do it for us.


        Stefan




This bug report was last modified 6 years and 16 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.