From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Joseph Turner via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#75188: persist.el should recursively copy hash tables Date: Mon, 30 Dec 2024 01:05:30 -0800 Message-ID: <87wmfhk0bp.fsf@breatheoutbreathe.in> Reply-To: Joseph Turner Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23117"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Adam Porter To: 75188@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Dec 30 10:06:27 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tSBjG-0005rl-1f for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 30 Dec 2024 10:06:26 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tSBiw-0006II-Kl; Mon, 30 Dec 2024 04:06:07 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tSBit-0006Hh-F5 for bug-gnu-emacs@gnu.org; Mon, 30 Dec 2024 04:06:03 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tSBit-0006en-62 for bug-gnu-emacs@gnu.org; Mon, 30 Dec 2024 04:06:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:From:To:Subject; bh=ibYSrThdKKkAyY/WdeU9vIR/UBxXqIy4KzC2voBYptk=; b=dgMKUdqwi/Twvj8gmWlmTl38VGgJU9Cm/okUKGwNbqI0b1W84Oaud5Bmq3Feip53GErUeH80rsXdTW/rnNDr5KPRBP35TQaN4Q7R+/fT53jHS4ObCoVSr+psFp1zl+3hiqYNRbiBvPbIEsFtJ1hWyGGM3oluvZtWB+Kg14azY1LJr82rVZgWx0rvaPm7upTeVmx57qHczlPNMjDCzr7wBikLH0YeJqccw4AW06qubi9ZWvH/WP7sB4tKLYUgoOJpBoRWFhnsQ2g38Gh43FXXRJlJuExyOvpiku+mQY3SFlM/YHPTYYJjYMh/TkMEX1a9PRwtDjSdWnL0IOLanRaaCQ==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tSBis-00058w-LE; Mon, 30 Dec 2024 04:06:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Joseph Turner Original-Sender: "Debbugs-submit" Resent-CC: adam@alphapapa.net, bug-gnu-emacs@gnu.org Resent-Date: Mon, 30 Dec 2024 09:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 75188 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org X-Debbugs-Original-Xcc: Adam Porter Original-Received: via spool by submit@debbugs.gnu.org id=B.173554955919759 (code B ref -1); Mon, 30 Dec 2024 09:06:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 30 Dec 2024 09:05:59 +0000 Original-Received: from localhost ([127.0.0.1]:57286 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tSBio-00058Z-Tp for submit@debbugs.gnu.org; Mon, 30 Dec 2024 04:05:59 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:46572) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tSBim-00058R-L0 for submit@debbugs.gnu.org; Mon, 30 Dec 2024 04:05:57 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tSBil-0006HM-6H for bug-gnu-emacs@gnu.org; Mon, 30 Dec 2024 04:05:55 -0500 Original-Received: from out-170.mta1.migadu.com ([95.215.58.170]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tSBid-0006ZS-Ho for bug-gnu-emacs@gnu.org; Mon, 30 Dec 2024 04:05:53 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=breatheoutbreathe.in; s=key1; t=1735549540; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=ibYSrThdKKkAyY/WdeU9vIR/UBxXqIy4KzC2voBYptk=; b=M/wlQR6EHmTL7YT+Oo7r3sMEAdOdjKUU6NsdQ/WxnLVMBq4TMsIv1g12Tj+gmVz+R+IVNF OfhO9fCyHOLnNbF3c8h04y0DmFHLJGs+L6b4R+szvwhZcHrcalIlZoCJDgM03RYdtZx/+Y FGyFgCI86nYi+iP17jJvVxWD9ZvdqHM= X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=95.215.58.170; envelope-from=joseph@breatheoutbreathe.in; helo=out-170.mta1.migadu.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:297987 Archived-At: --=-=-= Content-Type: text/plain 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. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Test-that-persist-copy-recursively-copies-hash-table.patch >From c28644c957d9fabf883990ff145cec19ed12ff10 Mon Sep 17 00:00:00 2001 From: Joseph Turner 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 --=-=-= Content-Type: text/plain 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@localhost/ Thank you! Joseph --=-=-=--