Could you run with -X:ExceptionDetail and report back the stack trace?  That'll 
let us know where the exception is actually coming from.

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Michael Foord
Sent: Friday, November 02, 2007 3:25 PM
To: Discussion of IronPython
Subject: [IronPython] Embedding CPython Messes with the IronPython 2 Import 
Mechanism

Hello Guys,

Not sure what is going on here, nor whether it indicates a bug in
IronPython, but it is certainly odd. Loading a CPython interpreter
through the Python.NET assembly seems to change the IronPython (2a5)
import machinery.

I have a test module 'xyzz.py' that has an unused name 'wibble'.
Unsurprisingly, attempting to import this into IronPython 2.0a5 raises a
name error:

IronPython console: IronPython 2.0A5 (2.0.11011.00) on .NET 2.0.50727.1378
Copyright (c) Microsoft Corporation. All rights reserved.
 >>> import xyzz
Traceback (most recent call last):
  File , line 0, in ##7
  File , line 0, in _stub_##2
  File C:\compile\cext\trunk\cext\xyzz.py, line 1, in Initialize
NameError: name 'wibble' is not defined


Executing the following code, (using the 'Python.Runtime' assembly from
Python.NET with Python 2.4):

IronPython console: IronPython 2.0A5 (2.0.11011.00) on .NET 2.0.50727.1378
Copyright (c) Microsoft Corporation. All rights reserved.
 >>> import clr
 >>> clr.AddReference('Python.Runtime')
 >>>
 >>> from Python.Runtime import PythonEngine
 >>> engine = PythonEngine()
 >>> engine.Initialize()
 >>>
 >>> import xyzz
Traceback (most recent call last):
  File , line 0, in ##18
  File , line 0, in _stub_##2
  File mscorlib, line unknown, in DefineDynamicAssembly
  File mscorlib, line unknown, in InternalDefineDynamicAssembly
TypeError: Unable to cast object of type 'System.Reflection.Module' to
type 'Sys
tem.Reflection.Emit.ModuleBuilder'.

Just importing the 'PythonEngine' isn't enough. The problem only happens
if the PythonEngine is instantiated and initialized.

All the best,


Michael


_______________________________________________
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