Skip to content

Instantly share code, notes, and snippets.

@ironpythonbot
Created December 9, 2014 18:10
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/6774d8e863c4ed6bd78e to your computer and use it in GitHub Desktop.
Save ironpythonbot/6774d8e863c4ed6bd78e to your computer and use it in GitHub Desktop.
CodePlex Issue #34602 Plain Text Attachments
namespace IPyImports
{
using IronPython.Hosting;
class Program
{
static void Main(string[] args)
{
var e = Python.CreateEngine();
var source = e.CreateScriptSourceFromString(string.Empty);
var result = source.Execute(); // no exceptions
var scope = e.CreateScope();
source = e.CreateScriptSourceFromString(@"from System import Guid");
result = source.Execute(scope); // serveral Exceptions: ImportException and TargetInvocationException
source = e.CreateScriptSourceFromString(@"from System import Guid");
result = source.Execute(scope); // no exceptions
source = e.CreateScriptSourceFromString(@"from System import DateTime");
result = source.Execute(); // no exceptions
source = e.CreateScriptSourceFromString(@"from System.Text import UTF8Encoding");
result = source.Execute(); // no exceptions
source = e.CreateScriptSourceFromString(@"from System.Text import UTF8Encoding
import sys
from System.Threading import Thread");
result = source.Execute(); // no exceptions
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment