Skip to content

Commit c0fb3f2

Browse files
yagwebvmuriart
authored andcommitted
Add unittest for Overflow/across AppDomains Exceptions reproduction (#393)
First exception shows issue from #376
1 parent f6d176c commit c0fb3f2

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/embed_tests/pyinitialize.cs

+28
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,33 @@ public static void StartAndStopTwice()
3636
PythonEngine.Initialize();
3737
PythonEngine.Shutdown();
3838
}
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+
}
3967
}
4068
}

0 commit comments

Comments
 (0)