https://github.com/python/cpython/commit/2cd0ddfe04afbe38bfbe73de1050ea5d1185f4b6
commit: 2cd0ddfe04afbe38bfbe73de1050ea5d1185f4b6
branch: main
author: Victor Stinner <[email protected]>
committer: vstinner <[email protected]>
date: 2026-03-05T14:14:04+01:00
summary:

gh-141510: Fix frozendict.items() ^ frozendict.items() (#145535)

Add non-regression tests.

files:
M Lib/test/test_dict.py
M Objects/dictobject.c

diff --git a/Lib/test/test_dict.py b/Lib/test/test_dict.py
index 162b0b38f8555d..45448d1264a53e 100644
--- a/Lib/test/test_dict.py
+++ b/Lib/test/test_dict.py
@@ -1848,11 +1848,19 @@ def test_merge(self):
                          frozendict({'x': 1, 'y': 2}))
         self.assertEqual(frozendict(x=1, y=2) | frozendict(y=5),
                          frozendict({'x': 1, 'y': 5}))
+        self.assertEqual(FrozenDict(x=1, y=2) | FrozenDict(y=5),
+                         frozendict({'x': 1, 'y': 5}))
+
         fd = frozendict(x=1, y=2)
         self.assertIs(fd | frozendict(), fd)
         self.assertIs(fd | {}, fd)
         self.assertIs(frozendict() | fd, fd)
 
+        fd = FrozenDict(x=1, y=2)
+        self.assertEqual(fd | frozendict(), fd)
+        self.assertEqual(fd | {}, fd)
+        self.assertEqual(frozendict() | fd, fd)
+
     def test_update(self):
         # test "a |= b" operator
         d = frozendict(x=1)
@@ -1863,6 +1871,11 @@ def test_update(self):
         self.assertEqual(d, frozendict({'x': 1, 'y': 2}))
         self.assertEqual(copy, frozendict({'x': 1}))
 
+    def test_items_xor(self):
+        # test "a ^ b" operator on items views
+        res = frozendict(a=1, b=2).items() ^ frozendict(b=2, c=3).items()
+        self.assertEqual(res, {('a', 1), ('c', 3)})
+
     def test_repr(self):
         d = frozendict()
         self.assertEqual(repr(d), "frozendict()")
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index 14019e4f1d926f..d86ab2634a9b13 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -6523,7 +6523,7 @@ dictitems_xor_lock_held(PyObject *d1, PyObject *d2)
     ASSERT_DICT_LOCKED(d1);
     ASSERT_DICT_LOCKED(d2);
 
-    PyObject *temp_dict = copy_lock_held(d1, PyFrozenDict_Check(d1));
+    PyObject *temp_dict = copy_lock_held(d1, 0);
     if (temp_dict == NULL) {
         return NULL;
     }

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to