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.

Author martin.panter
Recipients abarnert, abarry, curioswati, gvanrossum, martin.panter, ncoghlan, r.david.murray, rhettinger, serhiy.storchaka, terry.reedy
Date 2016-01-01.23:05:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1451689528.59.0.377494295026.issue25864@psf.upfronthosting.co.za>
In-reply-to
Content
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]
History
Date User Action Args
2016-01-01 23:05:28martin.pantersetrecipients: + martin.panter, gvanrossum, rhettinger, terry.reedy, ncoghlan, r.david.murray, serhiy.storchaka, abarnert, abarry, curioswati
2016-01-01 23:05:28martin.pantersetmessageid: <1451689528.59.0.377494295026.issue25864@psf.upfronthosting.co.za>
2016-01-01 23:05:28martin.panterlinkissue25864 messages
2016-01-01 23:05:28martin.pantercreate