[IronPython] IronPython 2: Bug in Indexing (Blocker)

Michael Foord michael.foord at resolversystems.com
Wed Nov 5 17:03:25 CET 2008

Hello Guys,

Discovered a bug in indexing Python objects in IronPython 2.

The following code:

class X(object):
    def __setitem__(self, key, value):
        print repr(key)

def f(a, b):
    X()[a, b] = object()
f(1, 2)
f('one', 'two')

Produces the following exception:

Traceback (most recent call last):
  File "bugtest.py", line 9, in bugtest.py
  File "bugtest.py", line 6, in f
TypeError: Specified cast is not valid.

It looks like IronPython has a call site that is now expecting integers 
the second time round.

Switching to using explicit tuples for indexing works around the problem:

    X()[(a, b)] = object()

However this kind of indexing is an *extremely* common way to use our 
spreadsheet API from user code, so we couldn't release with this bug in 

(Doing the indexing outside of the function also avoids the problem 
interestingly enough.)

All the best,

Michael Foord


Michael Foord
Senior Software Engineer, Resolver Systems Ltd.
michael.foord at resolversystems.com
+44 (0) 20 7253 6372

Try out Resolver One! <http://www.resolversystems.com/get-it/>

17a Clerkenwell Road, London EC1M 5RD, UK
VAT No.: GB 893 5643 79 Registered in England and Wales as company number 5467329.
Registered address: 843 Finchley Road, London NW11 8NA, UK 

More information about the Ironpython-users mailing list