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

Dino Viehland dinov at exchange.microsoft.com
Mon Jul 30 17:31:39 CEST 2007

This one is definite a bug - all the methods on array should always be visible.  I've created work item 11971 for the issue (http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=11971).  I've tentatively lumped it in 1.1.1 but having not looked at the issue I don't know how invasive the fix will be - but I suspect it will be fairly simple.

-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord
Sent: Saturday, July 28, 2007 6:15 AM
To: Discussion of IronPython
Subject: [IronPython] [Bug] Arrays are stripped of .NET methods / properties

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

Users mailing list
Users at lists.ironpython.com

More information about the Ironpython-users mailing list