summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2007-02-01 21:01:21 (GMT)
committerRaymond Hettinger <python@rcn.com>2007-02-01 21:01:21 (GMT)
commit21191f4f0c7f519d8b9fbb70c8c832f9e06fb243 (patch)
treee8e1b1555e1f9e2a68a841f995fd5f8c81dc8a0b
parentcd7a78e0a4130674b814934a9d77c92d9cbbf9be (diff)
downloadcpython-21191f4f0c7f519d8b9fbb70c8c832f9e06fb243.zip
cpython-21191f4f0c7f519d8b9fbb70c8c832f9e06fb243.tar.gz
cpython-21191f4f0c7f519d8b9fbb70c8c832f9e06fb243.tar.bz2
Bug #1648179: set.update() not recognizing __iter__ overrides in dict subclasses.
-rw-r--r--Misc/NEWS3
-rw-r--r--Objects/setobject.c8
2 files changed, 7 insertions, 4 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index ff8a082..303f4cf 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -16,6 +16,9 @@ Core and builtins
a weakref on itself during a __del__ call for new-style classes (classic
classes still have the bug).
+- Bug #1648179: set.update() did not recognize an overridden __iter__
+ method in subclasses of dict.
+
- Bug #1579370: Make PyTraceBack_Here use the current thread, not the
frame's thread state.
diff --git a/Objects/setobject.c b/Objects/setobject.c
index f038ee3..5b5fb3d 100644
--- a/Objects/setobject.c
+++ b/Objects/setobject.c
@@ -915,7 +915,7 @@ set_update_internal(PySetObject *so, PyObject *other)
if (PyAnySet_Check(other))
return set_merge(so, other);
- if (PyDict_Check(other)) {
+ if (PyDict_CheckExact(other)) {
PyObject *value;
Py_ssize_t pos = 0;
while (PyDict_Next(other, &pos, &key, &value)) {
@@ -1363,7 +1363,7 @@ set_difference(PySetObject *so, PyObject *other)
setentry *entry;
Py_ssize_t pos = 0;
- if (!PyAnySet_Check(other) && !PyDict_Check(other)) {
+ if (!PyAnySet_Check(other) && !PyDict_CheckExact(other)) {
result = set_copy(so);
if (result == NULL)
return NULL;
@@ -1377,7 +1377,7 @@ set_difference(PySetObject *so, PyObject *other)
if (result == NULL)
return NULL;
- if (PyDict_Check(other)) {
+ if (PyDict_CheckExact(other)) {
while (set_next(so, &pos, &entry)) {
setentry entrycopy;
entrycopy.hash = entry->hash;
@@ -1450,7 +1450,7 @@ set_symmetric_difference_update(PySetObject *so, PyObject *other)
if ((PyObject *)so == other)
return set_clear(so);
- if (PyDict_Check(other)) {
+ if (PyDict_CheckExact(other)) {
PyObject *value;
int rv;
while (PyDict_Next(other, &pos, &key, &value)) {