[Python-checkins] r54840 - in python/branches/release25-maint: Lib/test/test_dict.py Misc/NEWS Objects/dictobject.c

neal.norwitz python-checkins at python.org
Mon Apr 16 08:59:17 CEST 2007


Author: neal.norwitz
Date: Mon Apr 16 08:59:13 2007
New Revision: 54840

Modified:
   python/branches/release25-maint/Lib/test/test_dict.py
   python/branches/release25-maint/Misc/NEWS
   python/branches/release25-maint/Objects/dictobject.c
Log:
Revert SF #1615701 (rev 53655): dict.update() does *not* call __getitem__() or
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



Modified: python/branches/release25-maint/Lib/test/test_dict.py
==============================================================================
--- python/branches/release25-maint/Lib/test/test_dict.py	(original)
+++ python/branches/release25-maint/Lib/test/test_dict.py	Mon Apr 16 08:59:13 2007
@@ -189,14 +189,6 @@
 
         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 = {}

Modified: python/branches/release25-maint/Misc/NEWS
==============================================================================
--- python/branches/release25-maint/Misc/NEWS	(original)
+++ python/branches/release25-maint/Misc/NEWS	Mon Apr 16 08:59:13 2007
@@ -4,6 +4,18 @@
 
 (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?
 =============================
 

Modified: python/branches/release25-maint/Objects/dictobject.c
==============================================================================
--- python/branches/release25-maint/Objects/dictobject.c	(original)
+++ python/branches/release25-maint/Objects/dictobject.c	Mon Apr 16 08:59:13 2007
@@ -1352,7 +1352,7 @@
 		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 */


More information about the Python-checkins mailing list