Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 631bb43

Browse files
committed
Merge branch 'master' into soft-shutdown
2 parents 0b01378 + dbb88bc commit 631bb43

File tree

5 files changed

+156
-16
lines changed

5 files changed

+156
-16
lines changed

src/embed_tests/TestGILState.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
namespace Python.EmbeddingTest
2+
{
3+
using NUnit.Framework;
4+
using Python.Runtime;
5+
6+
public class TestGILState
7+
{
8+
/// <summary>
9+
/// Ensure, that calling <see cref="Py.GILState.Dispose"/> multiple times is safe
10+
/// </summary>
11+
[Test]
12+
public void CanDisposeMultipleTimes()
13+
{
14+
using (var gilState = Py.GIL())
15+
{
16+
for(int i = 0; i < 50; i++)
17+
gilState.Dispose();
18+
}
19+
}
20+
}
21+
}

src/embed_tests/TestPyObject.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,11 @@ def add(self, x, y):
5757
Assert.IsTrue(memberNames.Contains(expectedName), "Could not find member '{0}'.", expectedName);
5858
}
5959
}
60+
61+
[Test]
62+
public void InvokeNull() {
63+
var list = PythonEngine.Eval("list");
64+
Assert.Throws<ArgumentNullException>(() => list.Invoke(new PyObject[] {null}));
65+
}
6066
}
6167
}

src/runtime/pyint.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public PyInt(int value)
6262
/// Creates a new Python int from a uint32 value.
6363
/// </remarks>
6464
[CLSCompliant(false)]
65-
public PyInt(uint value) : base(IntPtr.Zero)
65+
public PyInt(uint value)
6666
{
6767
obj = Runtime.PyInt_FromInt64(value);
6868
Runtime.CheckExceptionOccurred();
@@ -75,7 +75,7 @@ public PyInt(uint value) : base(IntPtr.Zero)
7575
/// <remarks>
7676
/// Creates a new Python int from an int64 value.
7777
/// </remarks>
78-
public PyInt(long value) : base(IntPtr.Zero)
78+
public PyInt(long value)
7979
{
8080
obj = Runtime.PyInt_FromInt64(value);
8181
Runtime.CheckExceptionOccurred();
@@ -89,7 +89,7 @@ public PyInt(long value) : base(IntPtr.Zero)
8989
/// Creates a new Python int from a uint64 value.
9090
/// </remarks>
9191
[CLSCompliant(false)]
92-
public PyInt(ulong value) : base(IntPtr.Zero)
92+
public PyInt(ulong value)
9393
{
9494
obj = Runtime.PyInt_FromInt64((long)value);
9595
Runtime.CheckExceptionOccurred();

0 commit comments

Comments
 (0)