[IronPython] IPy embedding problem

Igor Elyas igor_elyas at hotmail.com
Mon Mar 16 15:31:03 CET 2009

Bug added to DLR project.

From: Curt Hagenlocher 
Sent: Sunday, March 15, 2009 11:50 PM
To: Discussion of IronPython 
Subject: Re: [IronPython] IPy embedding problem

Can you please open a bug for this on the DLR site (http://www.codeplex.com/dlr)?  There's a few methods that basically have code looking like this:

switch (parameters.Length) {
    case 0: // blah
    case 1: // blah
    case 2: // blah
        throw new NotImplementedException();

and these clearly need to be cleaned up.  I'm pretty sure there's a workaround for this, but a quick scan through the source code doesn't reveal anything obvious to me :(.  One possibility is to get "Checker" from the scope -- it may just give you a delegate you can call directly. 

On Sun, Mar 15, 2009 at 9:35 AM, Igor Elyas <igor_elyas at hotmail.com> wrote:


  This sample code throws error on Python object initialization:

              var engine = Python.CreateEngine();
              var Ops = engine.CreateOperations();
              var src =
  class Checker:
    def __init__(self, one, two, three=''):
      self.one = one
      self.two = two
      self.tree = three
    def Call(self):
      return self.one + self.two + self.tree

              var cs = engine.CreateScriptSourceFromString(src, SourceCodeKind.Statements).Compile();
              var tclass = cs.DefaultScope.GetVariable("Checker");
              object obj = cs.Engine.Operations.Call(tclass,"one","two","three");// throw NotImplementedException


  But if I use only 2 parameter in initialize/constructor such as :

             object obj = cs.Engine.Operations.Call(tclass,"one","two");

  , than all works fine. 

  What wrong ?

  Best regards
  Igor Elyas

  Users mailing list
  Users at lists.ironpython.com


Users mailing list
Users at lists.ironpython.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20090316/f32006fb/attachment.html>

More information about the Ironpython-users mailing list