New submission from Florent Xicluna <[email protected]>:
It looks like a bug, because __getslice__ is deprecated since 2.0.
If you subclass a builtin type and override the __getitem__ method, you need to
override the (deprecated) __getslice__ method too.
And if you run your program with "python -3", it
Example script:
class Upper(unicode):
def __getitem__(self, index):
return unicode.__getitem__(self, index).upper()
#def __getslice__(self, i, j):
#return self[i:j:]
if __name__ == '__main__':
text = Upper('Lorem ipsum')
print text[:]
print text[::]
----------
components: Interpreter Core
messages: 104148
nosy: flox
priority: normal
severity: normal
status: open
title: subclassing builtin class (str, unicode, list...) needs to override
__getslice__
type: behavior
versions: Python 2.7
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue8529>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com