[IronPython] __import__ bugs?

Kurt Blackwell kurt at blackwell.id.au
Sun Aug 20 09:02:38 CEST 2006

I'm quite new to Python in general, but one of the first things I wanted 
to try was to get IronPython to load scripts out of my own virtual 
directory system.  __import__ seemed like a good place to start, but 
IronPython seems to be doing things differently from CPython.

CPython expects you to overwrite __import__ in __builtins__, but that is 
read only in IronPython.  As far as I can tell, IronPython will only use 
your __import__ if it's a global.

The other thing is that the fromlist doesn't get what I would expect. 
Given the following:

def __import__(name, globals, locals, fromlist):
     print fromlist
from a import b

CPython will print "('b',)", but IronPython will print "[None]".  I'm 
guessing that's a bug.

More information about the Ironpython-users mailing list