[New-bugs-announce] [issue1259] string find and rfind methods give a TypeError that is misleading

Robert Collins report at bugs.python.org
Thu Oct 11 01:41:29 CEST 2007


New submission from 
					Robert Collins
				:

Python 2.5.1 (r251:54863, May  2 2007, 16:56:35) 
[GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 'asd'.find('s', None, None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: slice indices must be integers or None or have an __index__
method
>>> 'asd'.rfind('s', None, None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: slice indices must be integers or None or have an __index__
method
>>> # Note that this works, at the price of a memory copy,
>>> # and on large strings that is undesirable.
>>> 'asd'[None:None].find('s')
1
>>> 'asd'[None:None].rfind('s')
1
>>>

----------
messages: 56332
nosy: rbcollins
severity: normal
status: open
title: string find and rfind methods give a TypeError that is misleading
versions: Python 2.5

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1259>
__________________________________


More information about the New-bugs-announce mailing list