[IronPython] Iteration via __getitem__ doesn't work in the Visual Studio debugging environment
Tony Meyer
tony.meyer at gmail.com
Thu Sep 9 02:05:16 CEST 2010
I have this program:
class A(object):
def __init__(self):
self.data = range(5)
def __getitem__(self, item):
return self.data[item]
a = A()
for v in a:
print v
i.e. there's a class that gets iteration through the __getitem__
method. When run with IronPython in the shell (or with CPython), you
get the expected result:
C:\>"c:\Programs\IronPython 2.7\ipy.exe" Program.py
0
1
2
3
4
C:\>c:\Python27\python.exe Program.py
0
1
2
3
4
Underneath, of course, this is doing a[0], a[1], a[2], a[3], a[4], and
stopping when a[5] raises an IndexError.
When I run this in Visual Studio, the debugger catches the IndexError,
so this doesn't work. It seems like the exception should be allowed
to propagate further, so that the iteration works - but maybe this
just isn't compatible with how the debugger works?
(It's easy enough to fix this by defining _iter__, of course).
Is this a bug? Or just a limitation of how the debugging environment works?
Thanks,
Tony
More information about the Ironpython-users
mailing list