[Python-checkins] r53662 - in python/trunk: Lib/test/test_operator.py Objects/abstract.c

raymond.hettinger python-checkins at python.org
Wed Feb 7 23:24:08 CET 2007


Author: raymond.hettinger
Date: Wed Feb  7 23:24:07 2007
New Revision: 53662

Modified:
   python/trunk/Lib/test/test_operator.py
   python/trunk/Objects/abstract.c
Log:
Bug #1575169: operator.isSequenceType() now returns False for subclasses of dict.

Modified: python/trunk/Lib/test/test_operator.py
==============================================================================
--- python/trunk/Lib/test/test_operator.py	(original)
+++ python/trunk/Lib/test/test_operator.py	Wed Feb  7 23:24:07 2007
@@ -215,6 +215,8 @@
         self.failUnless(operator.isSequenceType(xrange(10)))
         self.failUnless(operator.isSequenceType('yeahbuddy'))
         self.failIf(operator.isSequenceType(3))
+        class Dict(dict): pass
+        self.failIf(operator.isSequenceType(Dict()))
 
     def test_lshift(self):
         self.failUnlessRaises(TypeError, operator.lshift)

Modified: python/trunk/Objects/abstract.c
==============================================================================
--- python/trunk/Objects/abstract.c	(original)
+++ python/trunk/Objects/abstract.c	Wed Feb  7 23:24:07 2007
@@ -1157,6 +1157,8 @@
 {
 	if (s && PyInstance_Check(s))
 		return PyObject_HasAttrString(s, "__getitem__");
+	if (PyObject_IsInstance(s, &PyDict_Type))
+		return 0;
 	return s != NULL && s->ob_type->tp_as_sequence &&
 		s->ob_type->tp_as_sequence->sq_item != NULL;
 }


More information about the Python-checkins mailing list