diff -r 099c7b0f24a6 Include/dictobject.h --- a/Include/dictobject.h Wed Jun 29 15:27:14 2011 -0500 +++ b/Include/dictobject.h Wed Jun 29 19:59:11 2011 -0400 @@ -104,6 +104,8 @@ /* This excludes Values, since they are not sets. */ # define PyDictViewSet_Check(op) \ (PyDictKeys_Check(op) || PyDictItems_Check(op)) +#define PyDictView_Check(op) \ + (PyDictViewSet_Check(op) || PyDictValues_Check(op)) PyAPI_FUNC(PyObject *) PyDict_New(void); diff -r 099c7b0f24a6 Lib/test/test_dictviews.py --- a/Lib/test/test_dictviews.py Wed Jun 29 15:27:14 2011 -0500 +++ b/Lib/test/test_dictviews.py Wed Jun 29 19:59:11 2011 -0400 @@ -68,6 +68,15 @@ values = d.values() self.assertEqual(set(values), {10, "ABC"}) self.assertEqual(len(values), 2) + self.assertIn(10, values) + self.assertIn("ABC", values) + self.assertNotIn(1, values) + self.assertNotIn("Z", values) + self.assertEqual(d.values(), d.values()) + e = {2: 10, "b": "ABC"} + self.assertEqual(d.values(), e.values()) + del e["b"] + self.assertNotEqual(d.values(), e.values()) def test_dict_repr(self): d = {1: 10, "a": "ABC"} diff -r 099c7b0f24a6 Objects/dictobject.c --- a/Objects/dictobject.c Wed Jun 29 15:27:14 2011 -0500 +++ b/Objects/dictobject.c Wed Jun 29 19:59:11 2011 -0400 @@ -2605,12 +2605,14 @@ PyObject *result; assert(self != NULL); - assert(PyDictViewSet_Check(self)); + assert(PyDictView_Check(self)); assert(other != NULL); - if (!PyAnySet_Check(other) && !PyDictViewSet_Check(other)) { - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; + if ((PyDictViewSet_Check(self) && + !PyAnySet_Check(other) && !PyDictViewSet_Check(other)) || + (PyDictValues_Check(self) && !PyDictValues_Check(other))) { + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; } len_self = PyObject_Size(self); @@ -3019,7 +3021,7 @@ 0, /* tp_setattr */ 0, /* tp_reserved */ (reprfunc)dictview_repr, /* tp_repr */ - 0, /* tp_as_number */ + &dictviews_as_number, /* tp_as_number */ &dictvalues_as_sequence, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ @@ -3032,7 +3034,7 @@ 0, /* tp_doc */ (traverseproc)dictview_traverse, /* tp_traverse */ 0, /* tp_clear */ - 0, /* tp_richcompare */ + dictview_richcompare, /* tp_richcompare */ 0, /* tp_weaklistoffset */ (getiterfunc)dictvalues_iter, /* tp_iter */ 0, /* tp_iternext */