Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ironpythonbot/29a792902edac0fafefd to your computer and use it in GitHub Desktop.
Save ironpythonbot/29a792902edac0fafefd to your computer and use it in GitHub Desktop.
CodePlex Issue #32530 Plain Text Attachments
using System;
using IronPython.Hosting;
using Microsoft.Scripting.Hosting;
class Program
{
static void Main()
{
ScriptEngine engine = Python.CreateEngine();
ScriptScope scope = engine.CreateScope();
// The following internally throws (and catches) a MissingMemberException,
// causing VS to break, (if in VS menu "Debug", "Exceptions...", "Common Language Runtime Exceptions", "System", column "Thrown" is checked for row "System.MissingMemberException")
// and printing this message to the Debug log:
// A first chance exception of type 'System.MissingMemberException' occurred in Anonymously Hosted DynamicMethods Assembly
bool b = scope.ContainsVariable("nonexisting");
Console.WriteLine("scope.ContainsVariable(\"nonexisting\") = {0}", b);
}
}
using System;
using IronPython.Hosting;
using Microsoft.Scripting.Hosting;
class Program
{
static void Main()
{
var engine = Python.CreateEngine();
var storage = new Dictionary<string, object>();
var scope = engine.CreateScope(storage);
engine.Execute("existing = 5", scope);
var a = storage.ContainsKey("existing");
var b = storage.ContainsKey("nonexisting");
Console.WriteLine("scope.ContainsVariable(\"existing\") = {0}", a);
Console.WriteLine("scope.ContainsVariable(\"nonexisting\") = {0}", b);
Console.ReadKey();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment