Martin Panter added the comment: IMO allowing any special method to be set to None seems to make more trouble than it is worth. Are there practical problems to address, or are they all theoretical?
Ideally I think it would be better to require __reversed__() for reverse() to work, but such a change would break compatibility. Regarding test_enumerate.py, your class looks like this: class Blocked(object): def __getitem__(self): return 1 def __len__(self): return 2 __reversed__ = None The signature of __getitem__() is wrong, and causes a TypeError during iteration, although your particular test does not go that far. When I see someone using assertRaises() with a common exception like TypeError, I instinctively suggest checking the message to avoid these kind of test case bugs. I suggest either remove __getitem__() if it serves no purpose, or change it to something like this if you really want an unreversible sequence: def __getitem__(self, index): return (1, 1)[index] ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25864> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com