This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: isSequenceType returns True for dict subclasses (<> 2.3)
Type: Stage:
Components: Interpreter Core Versions: Python 2.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: gfe, rhettinger
Priority: normal Keywords:

Created on 2006-10-11 10:35 by gfe, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg30208 - (view) Author: Martin Gfeller Martin Gfeller (gfe) Date: 2006-10-11 10:35
The following behavior is correct according to the 
documentation. However, it seems weird to me, and 
broke my code when going from 2.3 to 2.4:

Python  2.4.2:
>>> import operator
>>> class deriveddict(dict): pass
... 
>>> d =dict()
>>> dd = deriveddict()
>>> operator.isSequenceType(d)
False
>>> operator.isSequenceType(dd)
True


The last statement returns False in Python 2.3.4.




msg30209 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2006-11-27 18:28
Hmm, it may be possible to make the test smarter by checking base classes known mappings or known sequences in cases where the __getitem__ method hasn't been overridden.  That would reduce false positives in cases like this where there is some hint as to whether the __getitem__ method is for mapping or for sequence behavior.
msg30210 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2007-02-07 22:24
Fixed in revisions 53661 and 53662.
History
Date User Action Args
2022-04-11 14:56:20adminsetgithub: 44113
2006-10-11 10:35:09gfecreate