[Python-checkins] r53661 - in python/branches/release25-maint: Lib/test/test_operator.py Misc/NEWS Objects/abstract.c

raymond.hettinger python-checkins at python.org
Wed Feb 7 23:12:02 CET 2007


Author: raymond.hettinger
Date: Wed Feb  7 23:12:01 2007
New Revision: 53661

Modified:
   python/branches/release25-maint/Lib/test/test_operator.py
   python/branches/release25-maint/Misc/NEWS
   python/branches/release25-maint/Objects/abstract.c
Log:
Bug #1575169: operator.isSequenceType() now returns False for subclasses of dict.

Modified: python/branches/release25-maint/Lib/test/test_operator.py
==============================================================================
--- python/branches/release25-maint/Lib/test/test_operator.py	(original)
+++ python/branches/release25-maint/Lib/test/test_operator.py	Wed Feb  7 23:12:01 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/branches/release25-maint/Misc/NEWS
==============================================================================
--- python/branches/release25-maint/Misc/NEWS	(original)
+++ python/branches/release25-maint/Misc/NEWS	Wed Feb  7 23:12:01 2007
@@ -103,6 +103,8 @@
 Extension Modules
 -----------------
 
+- Bug #1575169: operator.isSequenceType() now returns False for subclasses of dict.
+
 - collections.defaultdict() now verifies that the factory function is callable.
 
 - Bug #1486663: don't reject keyword arguments for subclasses of builtin

Modified: python/branches/release25-maint/Objects/abstract.c
==============================================================================
--- python/branches/release25-maint/Objects/abstract.c	(original)
+++ python/branches/release25-maint/Objects/abstract.c	Wed Feb  7 23:12:01 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