Hello all,
If you patch __builtin__.__import__, even with something that delegates to the real __import__, then accessing .NET attributes can break.

Attached are two Python files, place them in the same directory and run:

   ipy first.py

and get this error:

Traceback (most recent call last):
 File "first.py", line 12, in first.py
 File "C:\buildshare\test.py", line 6, in function
AttributeError: 'int' object has no attribute 'MaxValue'

All it does is patch __import__ so that all imports are printed.

This is with Python 2.0.1.

All the best,

Michael
--
http://www.ironpythoninaction.com/


import __builtin__

old_import = __builtin__.__import__
def new_import(name, *args, **kwargs):
    print 'Importing', name
    return old_import(name, *args, **kwargs)

__builtin__.__import__ = new_import

from test import function

function()

from System import Int32

def function():
    print Int32.MaxValue
    
if __name__ == '__main__':
    function()
_______________________________________________
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to