[IronPython] str.rfind can raise index errors

Greg Chapman glc at well.com
Thu Jul 6 23:33:55 CEST 2006


Compare:

Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> s = 'x'
>>> s.rfind('x', 0, 0)
-1

IronPython 1.0.60619 (Beta) on .NET 2.0.50727.42
Copyright (c) Microsoft Corporation. All rights reserved.
>>> s = 'x'
>>> s.rfind('x', 0, 0)
Traceback (most recent call last):
  File , line 0, in <stdin>##57
  File , line 0, in RFind##60
  File mscorlib, line unknown, in LastIndexOf
  File mscorlib, line unknown, in LastIndexOf
ValueError: Index was out of range. Must be non-negative and less than the
size
of the collection.
Parameter name: startIndex

It looks like str.rfind needs to avoid calling String.LastIndexOf for empty
subranges of the string.





More information about the Ironpython-users mailing list