| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent f6d176c commit c0fb3f2
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -36,5 +36,33 @@ public static void StartAndStopTwice() | |||
| 36 | 36 | PythonEngine.Initialize(); | |
| 37 | 37 | PythonEngine.Shutdown(); | |
| 38 | 38 | } | |
| 39 | + | ||
| 40 | + [Test] | ||
| 41 | + [Ignore("System.OverflowException : Arithmetic operation resulted in an overflow")] | ||
| 42 | + //[Ignore("System.ArgumentException : Cannot pass a GCHandle across AppDomains")] | ||
| 43 | + public void ReInitialize() | ||
| 44 | + { | ||
| 45 | + string code = "from System import Int32\n"; | ||
| 46 | + PythonEngine.Initialize(); | ||
| 47 | + using (Py.GIL()) | ||
| 48 | + { | ||
| 49 | + //import any class or struct from .NET | ||
| 50 | + PythonEngine.RunSimpleString(code); | ||
| 51 | + } | ||
| 52 | + PythonEngine.Shutdown(); | ||
| 53 | + | ||
| 54 | + PythonEngine.Initialize(); | ||
| 55 | + using (Py.GIL()) | ||
| 56 | + { | ||
| 57 | + //Import a class/struct from .NET | ||
| 58 | + //This class/struct must be imported during the first initialization. | ||
| 59 | + PythonEngine.RunSimpleString(code); | ||
| 60 | + //Create an instance of the class/struct | ||
| 61 | + //System.OverflowException Exception will be raised here. | ||
| 62 | + //If replacing int with Int64, OverflowException will be replaced with AppDomain exception. | ||
| 63 | + PythonEngine.RunSimpleString("Int32(1)"); | ||
| 64 | + } | ||
| 65 | + PythonEngine.Shutdown(); | ||
| 66 | + } | ||
| 39 | 67 | } | |
| 40 | 68 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments