[New-bugs-announce] [issue11828] startswith and endswith don't accept None as slice index

Marijn Schouten report at bugs.python.org
Mon Apr 11 17:09:08 CEST 2011


New submission from Marijn Schouten <hkBst at gentoo.org>:

startswith and endswith don't accept None as slice index, as shown by below interaction. Same behavior for python-3.1.3(with print()) and python-2.7.1. If instead this is intended behavior then the error message is wrong.

$ python -c "print 'abc'[-1:None]"
c
$ python -c "print 'abc'.endswith('c',-1,None)"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
TypeError: slice indices must be integers or None or have an __index__ method

----------
components: None
messages: 133527
nosy: hkBst
priority: normal
severity: normal
status: open
title: startswith and endswith don't accept None as slice index
type: behavior
versions: Python 2.7, Python 3.1

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


More information about the New-bugs-announce mailing list