[IronPython] IronPython 2 Bug: Module Name Lookup Broken

Michael Foord fuzzyman at voidspace.org.uk
Wed Nov 19 13:55:46 CET 2008

Hello guys,

It looks like in source code drop 43712 module name lookup is broken if 
the name is also a .NET member name (presumably of Script or 
ScriptScope) and clr has not been imported.

To reproduce have a pure python module called 'check.py' containing:

def check(module):
    print module.Keys

If you also have a 'stuff.py' module containing:

Keys = 3

You get the following exception:

 >>> import stuff
 >>> from check import check
 >>> check(stuff)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Dev\buildshare\Ipy2-43712-binaries\check.py", line 2, in check
AttributeError: 'module' object has no attribute 'Keys'

(Interestingly 'Keys' does appear in the dir of the module.)

This is causing us problems in the use of unittest that does module 
introspection. It isn't blocking us as adding 'import clr' causes the 
problem to go away, but could well cause us other problems (we are still 
working our way through our last remaining 50 unit test failures in our 
IronPython 2 port.)

I have raised this as issue number 19656 on Codeplex:


All the best,

Michael Foord & Glenn Jones
Resolver Systems


More information about the Ironpython-users mailing list