]> granicus.if.org Git - python/commitdiff
Revert SF #1615701 (rev 53655): dict.update() does *not* call __getitem__() or
authorNeal Norwitz <nnorwitz@gmail.com>
Mon, 16 Apr 2007 06:59:13 +0000 (06:59 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Mon, 16 Apr 2007 06:59:13 +0000 (06:59 +0000)
keys() if subclassed.  This is to remain consistent with 2.5.

See discussion here:
  http://mail.python.org/pipermail/python-dev/2007-April/072565.html

Lib/test/test_dict.py
Misc/NEWS
Objects/dictobject.c

index e99c46d96554e9e2d06cda4b8f6c4cf61cf5acba..8da0915346c608663295622a100ae5b52cd31d2f 100644 (file)
@@ -189,14 +189,6 @@ class DictTest(unittest.TestCase):
 
         self.assertRaises(ValueError, {}.update, [(1, 2, 3)])
 
-        # SF #1615701:  make d.update(m) honor __getitem__() and keys() in dict subclasses
-        class KeyUpperDict(dict):
-            def __getitem__(self, key):
-                return key.upper()
-        d.clear()
-        d.update(KeyUpperDict.fromkeys('abc'))
-        self.assertEqual(d, {'a':'A', 'b':'B', 'c':'C'})
-
     def test_fromkeys(self):
         self.assertEqual(dict.fromkeys('abc'), {'a':None, 'b':None, 'c':None})
         d = {}
index d2264c43d0930c310df213bc1915a34236d4c8b0..bd76c87937b7ed2e01cf411ce9725044b70f9329 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -4,6 +4,18 @@ Python News
 
 (editors: check NEWS.help for information about editing NEWS using ReST.)
 
+What's New in Python 2.5.1?
+=============================
+
+*Release date: XX-APR-2007*
+
+Core and builtins
+-----------------
+
+- Revert SF #1615701: dict.update() does *not* call __getitem__() or keys()
+  if subclassed.  This is to remain consistent with 2.5.
+
+
 What's New in Python 2.5.1c1?
 =============================
 
index bc3cd53ebeabf9383dc23586750d31bcd39c6ce5..af0d6f37aef860ac167e8c73a804bd6cac7fe88b 100644 (file)
@@ -1352,7 +1352,7 @@ PyDict_Merge(PyObject *a, PyObject *b, int override)
                return -1;
        }
        mp = (dictobject*)a;
-       if (PyDict_CheckExact(b)) {
+       if (PyDict_Check(b)) {
                other = (dictobject*)b;
                if (other == mp || other->ma_used == 0)
                        /* a.update(a) or a.update({}); nothing to do */