GNU bug report logs -
#75188
persist.el should recursively copy hash tables
Previous Next
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Your message dated Thu, 13 Feb 2025 01:54:11 -0800
with message-id <CADwFkm=QsKmwuUU7rWGOZP+jujYMf1FP10CZX-pOhVgSaC=44w <at> mail.gmail.com>
and subject line Re: bug#75188: persist.el should recursively copy hash tables
has caused the debbugs.gnu.org bug report #75188,
regarding persist.el should recursively copy hash tables
to be marked as done.
(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)
--
75188: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=75188
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
[Message part 3 (text/plain, inline)]
Hello!
This patch demonstrates a bug in persist.el, which may be the cause of
https://github.com/alphapapa/activities.el/issues/109 and a similar bug
in hyperdrive.el which causes the `persist' variable file to be deleted.
We have not yet found a way to reproduce the bug in either activities.el
or hyperdrive.el, so this `persist' bug may be unrelated.
[0001-Test-that-persist-copy-recursively-copies-hash-table.patch (text/x-diff, inline)]
From c28644c957d9fabf883990ff145cec19ed12ff10 Mon Sep 17 00:00:00 2001
From: Joseph Turner <joseph <at> breatheoutbreathe.in>
Date: Mon, 30 Dec 2024 00:40:33 -0800
Subject: [PATCH] Test that persist-copy recursively copies hash tables
---
test/persist-tests.el | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/test/persist-tests.el b/test/persist-tests.el
index 6bf2ed3708..adf37a5bf0 100644
--- a/test/persist-tests.el
+++ b/test/persist-tests.el
@@ -151,3 +151,14 @@ (ert-deftest test-persist-reset ()
(should-not (eq persist--test-reset-variable initial-value))
(should-not (eq initial-value
(persist-default 'persist--test-reset-variable))))))
+
+(ert-deftest test-persist-copy-hash-table ()
+ "`persist-copy' should copy hash keys and values."
+ (let* ((hash (make-hash-table))
+ (rec (record 'a))
+ (_ (puthash 'foo rec hash))
+ (copy-hash (persist-copy hash)))
+ (setf (aref (gethash 'foo copy-hash) 0) 'b)
+ (should-not (persist-equal hash copy-hash))
+ (should-not (eq (gethash 'foo hash)
+ (gethash 'foo copy-hash)))))
--
2.46.0
[Message part 5 (text/plain, inline)]
IIUC, the solution requires rewriting `persist-copy-tree' (which is
copied from Emacs 30's `copy-tree') so that it handles hash tables. If
you all agree, I can do this in `persist.el`.
However, would it make sense for `copy-tree' to handle hash tables?
Forgive me if this has been discussed and settled before. I did find
this thread about comparing hash tables with `equal':
https://yhetil.org/emacs-devel/871qvz4kdw.fsf <at> localhost/
Thank you!
Joseph
[Message part 6 (message/rfc822, inline)]
Eli Zaretskii <eliz <at> gnu.org> writes:
>> From: Joseph Turner <joseph <at> breatheoutbreathe.in>
>> Cc: 75188 <at> debbugs.gnu.org, mail <at> daniel-mendler.de, yantar92 <at> posteo.net,
>> monnier <at> iro.umontreal.ca, adam <at> alphapapa.net,
>> phillip.lord <at> russet.org.uk
>> Date: Mon, 27 Jan 2025 18:08:57 -0800
>>
>> Eli Zaretskii <eliz <at> gnu.org> writes:
>>
>> >> From: Joseph Turner <joseph <at> breatheoutbreathe.in>
>> >> Cc: Daniel Mendler <mail <at> daniel-mendler.de>,
>> >> Ihor Radchenko <yantar92 <at> posteo.net>,
>> >> Stefan Monnier <monnier <at> iro.umontreal.ca>,
>> >> Adam Porter <adam <at> alphapapa.net>, Eli Zaretskii <eliz <at> gnu.org>,
>> >> phillip.lord <at> russet.org.uk
>> >> Date: Tue, 31 Dec 2024 14:12:00 -0800
>> >>
>> >> > Hello!
>> >> >
>> >> > This patch demonstrates a bug in persist.el
>> >>
>> >> [...]
>> >>
>> >> This issue also relates to the bug#63513, in which the suggestion was
>> >> made to replace persist-copy-tree with (compat-call copy-tree) now that
>> >> Compat 30 is available:
>> >>
>> >> https://yhetil.org/emacs-bugs/80479897-500e-fe60-6586-0a44ccb5993b <at> daniel-mendler.de/
>> >
>> > Thanks, would you like to submit a patch along those lines?
>>
>> Please see patch:
>
> LGTM. Phillip, would you please install?
I'm not Phillip, but I installed the patch now. Closing.
This bug report was last modified 177 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.