Thank you very much, great repro, which points to an IronPython bug which I opened on CodePlex (bug 940)

 

http://www.codeplex.com/WorkItem/View.aspx?ProjectName=IronPython&WorkItemId=940

 

in fact, the actual repro is even simpler, no need to declare the TestClass either, simply import minidom and exception happens.

 

>>> import sys

>>> sys.path.append(r"C:\Python24\Lib")

>>> import xml.dom.minidom

Traceback (most recent call last):

  File , line 0, in <stdin>##8

  File , line 0, in __import__##5

  File C:\Python24\Lib\xml\dom\minidom.py, line 462, in Initialize

TypeError: Unable to cast object of type 'IronPython.Runtime.Types.OldClass' to type 'IronPython.Runtime.Types.DynamicType'.

 

Martin


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Mike Raath
Sent: Friday, July 14, 2006 12:18 AM
To: Discussion of IronPython
Subject: Re: [IronPython] Unable to cast object of type 'IronPython.Runtime.Types.OldClass' to type 'IronPython.Runtime.Types.DynamicType'

 

OK - I've broken it down to its simplest form. It looks like there's a problem importing the minidom class.

If you create a module TestModule.py containing the following code:

Python Code
==========
import xml.dom.minidom

class TestClass:
    pass


and then try to import this class you will see this error.

My C# code is as follows:
====================
            PythonEngine engine = new PythonEngine();

            engine.AddToPath("C:\\Python24\\lib");
            engine.AddToPath("C:\\Temp\\IronPythonTest\\IronPythonTest\\Python\\");
            engine.Execute("from TestModule import TestClass");


Mike

On 7/13/06, Martin Maly <[EMAIL PROTECTED]> wrote:

However, that said, in Beta 9, the OldClass is no longer a DynamicType, which explains the exception itself. To find out what you need to change in your code is something that we'll need more info for.

 

For example, the exception can come from anywhere in the Module body (during import, the module body gets executed – unless the module has been already imported). Since I don't get exception when executing "from Module import Class", I suspect that this is what may be the case. The call stack for the exception could help find out what line in your module code is throwing.

 

M.

 


From: [EMAIL PROTECTED] [mailto: [EMAIL PROTECTED]] On Behalf Of Martin Maly
Sent: Thursday, July 13, 2006 8:09 AM
To: Discussion of IronPython
Subject: Re: [IronPython] Unable to cast object of type 'IronPython.Runtime.Types.OldClass' to type 'IronPython.Runtime.Types.DynamicType'

 

To help you, we will need more information about your use of the Python Engine. The simple case of executing "from Module import Class" does work so we need to know more to find out what the problem may be.

 

Thanks

Martin

 


From: [EMAIL PROTECTED] [mailto: [EMAIL PROTECTED]] On Behalf Of Mike Raath
Sent: Thursday, July 13, 2006 1:41 AM
To: Discussion of IronPython
Subject: [IronPython] Unable to cast object of type 'IronPython.Runtime.Types.OldClass' to type 'IronPython.Runtime.Types.DynamicType'

 

Hi

Having tried to switch over to beta 9, and changing my generic Evaluate<T> references to EvaluateAs<T>, I get a runtime error on an import statement which works under beta 8. The exception is as is detailed in the message above, and is from a statement like
engine.Execute("from Module import Class);

The Module and Class definitions are custom - and as i say this statement works under beta 8.

Do you require more information or do I need to make a further change to my code to get it to work?

Thanks,
Mike


_______________________________________________
users mailing list
users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

 

_______________________________________________
users mailing list
users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to