Bug #1575169: operator.isSequenceType() now returns False for subclasses of dict.
This commit is contained in:
parent
113776c411
commit
127ef44c7b
|
@ -215,6 +215,8 @@ class OperatorTestCase(unittest.TestCase):
|
|||
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)
|
||||
|
|
|
@ -103,6 +103,8 @@ Core and builtins
|
|||
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
|
||||
|
|
|
@ -1157,6 +1157,8 @@ PySequence_Check(PyObject *s)
|
|||
{
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue