[IronPython] str.rfind can raise index errors

Haibo Luo haiboluo at exchange.microsoft.com
Fri Jul 7 00:05:38 CEST 2006

Thanks for the bug report. I opened one work item in codeplex: http://www.codeplex.com/WorkItem/View.aspx?ProjectName=IronPython&WorkItemId=811

-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Greg Chapman
Sent: Thursday, July 06, 2006 2:34 PM
To: users at lists.ironpython.com
Subject: [IronPython] str.rfind can raise index errors


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

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
of the collection.
Parameter name: startIndex

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

users mailing list
users at lists.ironpython.com

More information about the Ironpython-users mailing list