summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2007-04-16 06:59:13 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2007-04-16 06:59:13 (GMT)
commite6e383f4984c71a0126743474ac4ca209dd946b6 (patch)
tree457b3db806e489a59f0ff9e9881e3aa89aa5c791
parent8d61db5a004f04f7cfc2105f9c092ba97bc08ce4 (diff)
downloadcpython-e6e383f4984c71a0126743474ac4ca209dd946b6.zip
cpython-e6e383f4984c71a0126743474ac4ca209dd946b6.tar.gz
cpython-e6e383f4984c71a0126743474ac4ca209dd946b6.tar.bz2
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
-rw-r--r--Lib/test/test_dict.py8
-rw-r--r--Misc/NEWS12
-rw-r--r--Objects/dictobject.c2
3 files changed, 13 insertions, 9 deletions
diff --git a/Lib/test/test_dict.py b/Lib/test/test_dict.py
index e99c46d..8da0915 100644
--- a/Lib/test/test_dict.py
+++ b/Lib/test/test_dict.py
@@ -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 = {}
diff --git a/Misc/NEWS b/Misc/NEWS
index d2264c4..bd76c87 100644
--- 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?
=============================
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index bc3cd53..af0d6f3 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -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 */