[IronPython] [Bug] Arrays are stripped of .NET methods / properties

Michael Foord fuzzyman at voidspace.org.uk
Sat Jul 28 15:14:58 CEST 2007


Hello all,

A bug in IronPython 1.1. This one has bitten us and it would be very 
nice to have it fixed.

Create a .NET array in one module and then use it in another module that 
hasn't imported clr (or System) and it will be stripped of its .NET 
methods and properties.

Importing clr fixes the problem, but shouldn't be necessary (right?).

To see this, create a module called 'createArray.py':

from System import Array

def CreateArray():
    return Array.CreateInstance(int, 2, 2)


Then use the module from another IronPython program. E.g. :

from createArray import CreateArray

array = CreateArray()
print array.Rank

This results in the following error:

C:\>ipy testArray.py
Traceback (most recent call last):
  File C:\testArray.py, line 4, in Initialize
AttributeError: 'Array[int]' object has no attribute 'Rank'

If you add an import clr to the program then it does the right thing...

Michael Foord
http://www.ironpython.info




More information about the Ironpython-users mailing list