Problem with indexers of generic collections
description
For generic .NET types the problem happens when a first access to the indexer is wrong, for example:
Right:
IronPython 2.7 Alpha 1 (2.7.0.1) on .NET 4.0.30319.1
Type "help", "copyright", "credits" or "license" for more information.
>>> import System
>>> d = System.Collections.Generic.Dictionary[str, int]()
>>> d['0']
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyError: The given key was not present in the dictionary.
>>> d[0]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: expected str, got int
>>> d['0']
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyError: The given key was not present in the dictionary.
Wrong:
IronPython 2.7 Alpha 1 (2.7.0.1) on .NET 4.0.30319.1
Type "help", "copyright", "credits" or "license" for more information.
>>> import System
>>> d = System.Collections.Generic.Dictionary[str, int]()
>>> d[0]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: expected str, got int
>>> d['0']
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'str' object has no attribute '__index__'
>>> d.__getitem__('0')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyError: The given key was not present in the dictionary.