[IronPython] TypeError: integer expected occurs when __getitem__ is called

Sanghyeon Seo sanxiyn at gmail.com
Sat Aug 11 05:49:06 CEST 2007

2007/8/11, Tianyong Tang <tiyota at gmail.com>:
> I am a newbie with  IronPython,  and want to test pysnmp eggs of CPython in
> IronPython.
> It works in CPython, but when I try it in IronPython, error occurred with
> the import of libraries at the beginning: (snip)
> File C:\Python25\lib\site-packages\pyasn1\v1\type\tag.py,
> line 84, in tagImplicitly
> File C:\Python25\lib\site-packages\pyasn1\v1\type\tag.py,
> line 89, in __getitem__
> TypeError: integer expected

This is IronPython issue #2728, reported last year.

For the IronPython team: here's the relevant lines in the traceback:

# A method of TagSet old-style class
def tagImplicitly(self, superTag):
  # some lines omitted
  return self[:-1] + superTag

So the index type is slice(None, -1, None), and the index should be
converted by calling __len__ (which IronPython doesn't do). And then
__getitem__ tries to index by None and TypeError is raised.

Seo Sanghyeon

More information about the Ironpython-users mailing list