[issue27479] Slicing strings out of bounds does not raise IndexError

Elizabeth Myers report at bugs.python.org
Sun Jul 10 21:04:08 EDT 2016


New submission from Elizabeth Myers:

When slicing strings, IndexError is not raised when the slices are out of bounds, even for negative indexes. Like so:

>>> "test"[-1000:1000]
'test'

>>> "test"[-1000:1]
't'

>>> ""[-100:100]
''

This seems more like a bug than useful behaviour to me.

----------
messages: 270147
nosy: Elizacat
priority: normal
severity: normal
status: open
title: Slicing strings out of bounds does not raise IndexError
versions: Python 2.7, Python 3.4, Python 3.5, Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27479>
_______________________________________


More information about the Python-bugs-list mailing list