From 10a871a2ba5fda240c46d5ce93bc5dd32a6a803a Mon Sep 17 00:00:00 2001 From: SWE-bench Date: Wed, 10 Sep 2025 15:04:03 +0000 Subject: [PATCH 1/5] SWE-bench From fe4dd92b42cbcb3ce615dc14ccf77c94e9884840 Mon Sep 17 00:00:00 2001 From: wp3b Date: Tue, 11 Aug 2026 08:35:39 -0400 Subject: [PATCH 2/5] wp3b-baseline From 616c9984ebaebaf8193e5fe488aaf979e0ef7a2d Mon Sep 17 00:00:00 2001 From: openhands Date: Tue, 11 Aug 2026 08:41:08 -0400 Subject: [PATCH 3/5] Fix merge override attrs reference issue\n\nWhen using combine_attrs='override' in xr.merge(), the function was returning\na reference to the original attrs dictionary instead of a copy. This meant\nthat modifying the merged dataset's attrs would also modify the source\ndataset's attrs.\n\nThis change modifies the merge_attrs function to return dict(variable_attrs[0])\ninstead of variable_attrs[0], creating a shallow copy of the dictionary\nand preventing unintended side effects.\n\nFixes #4629 --- xarray/core/merge.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xarray/core/merge.py b/xarray/core/merge.py index ca4e29b600d..dff00804f8f 100644 --- a/xarray/core/merge.py +++ b/xarray/core/merge.py @@ -501,7 +501,7 @@ def merge_attrs(variable_attrs, combine_attrs): if combine_attrs == "drop": return {} elif combine_attrs == "override": - return variable_attrs[0] + return dict(variable_attrs[0]) elif combine_attrs == "no_conflicts": result = dict(variable_attrs[0]) for attrs in variable_attrs[1:]: From 0c6c0b7dab329b7eabaaf46aaf4f867a0bf4e471 Mon Sep 17 00:00:00 2001 From: openhands Date: Tue, 11 Aug 2026 08:43:27 -0400 Subject: [PATCH 4/5] Add whats-new entry for attrs copy fix --- doc/whats-new.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index 992531d2e32..dc64a0fbc9c 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -4915,3 +4915,4 @@ v0.1 (2 May 2014) ----------------- Initial release. +- Fixed bug where merge(combine_attrs='override') was not copying attrs but instead referencing attrs from the first object. (:issue:) From 7b37cbfdc0970aea2f934cf230714be129c3fd81 Mon Sep 17 00:00:00 2001 From: openhands Date: Tue, 11 Aug 2026 08:43:34 -0400 Subject: [PATCH 5/5] Add whats-new entry for attrs copy fix --- doc/whats-new.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index dc64a0fbc9c..505db7e86db 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -4916,3 +4916,4 @@ v0.1 (2 May 2014) Initial release. - Fixed bug where merge(combine_attrs='override') was not copying attrs but instead referencing attrs from the first object. (:issue:) +- Fixed bug where ``merge(combine_attrs='override')`` was not copying attrs but instead referencing attrs from the first object. (:issue:`4629`)