From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.bugs Subject: bug#29220: 26.0.90; eieio-persistent-read fail to restore saved object. Date: Mon, 04 Dec 2017 17:27:04 -0800 Message-ID: <87h8t69d7b.fsf@ericabrahamsen.net> References: <87y3nga0lv.fsf@killashandra.ballybran.fr> <87po8s8k02.fsf@ericabrahamsen.net> <87zi7udorn.fsf@killashandra.ballybran.fr> <8760aim2a5.fsf@ericabrahamsen.net> <87375j2tzd.fsf@users.sourceforge.net> <87inecwl1v.fsf@killashandra.ballybran.fr> <87y3n81eq7.fsf@users.sourceforge.net> <87h8ts1cfp.fsf@users.sourceforge.net> <87zi7kyzcf.fsf@ericabrahamsen.net> <87efov1zzn.fsf@users.sourceforge.net> <87h8trzc6e.fsf@ericabrahamsen.net> <87bmjz0xez.fsf@users.sourceforge.net> <87zi7cpooo.fsf@killashandra.ballybran.fr> <87h8tkzgef.fsf@users.sourceforge.net> <87zi76f5hj.fsf@killashandra.ballybran.fr> <87shcycavk.fsf@ericabrahamsen.net> <87lgimpdhp.fsf@ericabrahamsen.net> <87h8t8is1u.fsf@ericabrahamsen.net> <87zi6zmzh7.fsf@killashandra.ballybran.fr> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1512437292 21901 195.159.176.226 (5 Dec 2017 01:28:12 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 5 Dec 2017 01:28:12 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 29220@debbugs.gnu.org, Stefan Monnier , Noam Postavsky To: pierre.techoueyres@free.fr (Pierre =?UTF-8?Q?T=C3=A9choueyres?=) Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Dec 05 02:28:07 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eM21k-0005Fe-US for geb-bug-gnu-emacs@m.gmane.org; Tue, 05 Dec 2017 02:28:05 +0100 Original-Received: from localhost ([::1]:45939 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eM21s-0005RK-27 for geb-bug-gnu-emacs@m.gmane.org; Mon, 04 Dec 2017 20:28:12 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53193) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eM21l-0005RE-Ih for bug-gnu-emacs@gnu.org; Mon, 04 Dec 2017 20:28:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eM21i-00080C-Dd for bug-gnu-emacs@gnu.org; Mon, 04 Dec 2017 20:28:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:37485) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eM21i-000800-7p for bug-gnu-emacs@gnu.org; Mon, 04 Dec 2017 20:28:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eM21h-0000AQ-Sy for bug-gnu-emacs@gnu.org; Mon, 04 Dec 2017 20:28:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eric Abrahamsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 05 Dec 2017 01:28:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 29220 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 29220-submit@debbugs.gnu.org id=B29220.1512437234588 (code B ref 29220); Tue, 05 Dec 2017 01:28:01 +0000 Original-Received: (at 29220) by debbugs.gnu.org; 5 Dec 2017 01:27:14 +0000 Original-Received: from localhost ([127.0.0.1]:46166 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eM20w-00009Q-65 for submit@debbugs.gnu.org; Mon, 04 Dec 2017 20:27:14 -0500 Original-Received: from mail.ericabrahamsen.net ([50.56.99.223]:34268) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eM20u-00009G-Im for 29220@debbugs.gnu.org; Mon, 04 Dec 2017 20:27:13 -0500 Original-Received: from localhost (71-212-22-173.tukw.qwest.net [71.212.22.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) (Authenticated sender: eric@ericabrahamsen.net) by mail.ericabrahamsen.net (Postfix) with ESMTPSA id AD858C0541; Tue, 5 Dec 2017 01:27:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mail.ericabrahamsen.net; s=mail; t=1512437231; bh=R13+iQTJOzn0+EkHWIRtHEhcBvXfMfvFOTxPdddXa+I=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=ESyyZnE8RrFcQtWSGg5+96vzfF7n3FvIx5zNTvw0YHhth5Xx8bbdpoO+AGiOrvRws 0iwif7VKm76ZmSZ58+wtoYS/P/O55Tl+FSDjf7v0axussCNXzfxXpLx72Ur1JzPCWt L4DCfbFZZNP9WkbEdqhaC3+THejxn3wzSWqz7ovY= In-Reply-To: <87zi6zmzh7.fsf@killashandra.ballybran.fr> ("Pierre =?UTF-8?Q?T=C3=A9choueyres?="'s message of "Sun, 03 Dec 2017 19:35:16 +0100") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:140708 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 12/03/17 19:35 PM, Pierre T=C3=A9choueyres wrote: > Eric Abrahamsen writes: > >> On 12/01/17 12:55 PM, Stefan Monnier wrote: >>>>> So I think the real fix here is to extend eieio-persistent with suppo= rt >>>>> for hash-tables. >>>> Just hash tables? >>> >>> For the problem at hand, IIUC, hash-tables is what's needed, yes. >>> >>>> How about vectors? >>> >>> Sure, add that too. >> >> Before I do that, I just opened #29541 with a proposal for tweaking the >> restore process -- maybe that could be done first? >> > > I wishes it would, but this is a blocker bug for emacs 26, isn't it ? Could be! If so, let's fix this part first. Here's a diff that seems to work. The read->with-output-to-string stuff seems awful to me, and I'm hoping someone has something more elegant on hand. Eric --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=persistent-stuff.diff diff --git a/lisp/emacs-lisp/eieio-base.el b/lisp/emacs-lisp/eieio-base.el index 58dcd09d7e..840f7223c4 100644 --- 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))) (defun eieio-persistent-slot-type-is-class-p (type) "Return the class referred to in TYPE. diff --git a/lisp/emacs-lisp/eieio.el b/lisp/emacs-lisp/eieio.el index d0d2ff5145..11637c8072 100644 --- a/lisp/emacs-lisp/eieio.el +++ b/lisp/emacs-lisp/eieio.el @@ -926,6 +926,23 @@ eieio-override-prin1 (object-write thing)) ((consp thing) (eieio-list-prin1 thing)) + ((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)) ((eieio--class-p thing) (princ (eieio--class-print-name thing))) (t (prin1 thing)))) --=-=-=--