Hi ironpython,

Here's your Daily Digest of new issues for project "IronPython".

In today's digest:ISSUES

1. [New comment] ScriptScope.ContainsVariable throws MissingMemberException 
internally
2. [New comment] ScriptScope.ContainsVariable throws MissingMemberException 
internally

----------------------------------------------

ISSUES

1. [New comment] ScriptScope.ContainsVariable throws MissingMemberException 
internally
http://ironpython.codeplex.com/workitem/32530
User KeithJRome has commented on the issue:

"This happens because ContainsVariable() internally routes through IDMOP's 
BindGetMember and attempts to form a CallSite. Since your IDMOP container (the 
ScriptScope) has no member of that name, it throws an exception deep down in 
the DLR when it tries to resolve that unresolvable CallSite.

You can avoid the whole problem if you just call GetVariableNames() instead, 
and use Contains() on that. The last two lines of the following code are 
functionally identical, except for the exception-throwing behavior:

            var engine = Python.CreateEngine();
            var test = engine.CreateScope();
            bool tmp;

            tmp = test.GetVariableNames().Contains("foo");
            tmp = test.ContainsVariable("foo");
"-----------------

2. [New comment] ScriptScope.ContainsVariable throws MissingMemberException 
internally
http://ironpython.codeplex.com/workitem/32530
User KeithJRome has commented on the issue:

"In fact, I see no reason why ContainsVariable() shouldn't just use the 
GetMemberNames().Contains() form. It would be far more lightweight, yes?

The only "downside" I can think of is perhaps the current form exercises a lot 
more of the DLR binding and might catch dynamic dispatch problems more quickly?

The current design is logically the same as doing this, but with a lot more 
ceremony:

public bool ContainsVariable(ScriptScope test)
{
  dynamic bar = test;
  try {
    var dummy = bar.foo;
    return true;
  } catch {
    return false;
  }
}

And of course, if we saw that in our own code we would probably shiver a little 
bit.
"
----------------------------------------------



----------------------------------------------
You are receiving this email because you subscribed to notifications on 
CodePlex.

To report a bug, request a feature, or add a comment, visit IronPython Issue 
Tracker. You can unsubscribe or change your issue notification settings on 
CodePlex.com.
_______________________________________________
Ironpython-users mailing list
Ironpython-users@python.org
http://mail.python.org/mailman/listinfo/ironpython-users

Reply via email to