| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff 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 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -57,5 +57,11 @@ def add(self, x, y): | |||
| 57 | 57 | Assert.IsTrue(memberNames.Contains(expectedName), "Could not find member '{0}'.", expectedName); | |
| 58 | 58 | } | |
| 59 | 59 | } | |
| 60 | + | ||
| 61 | + [Test] | ||
| 62 | + public void InvokeNull() { | ||
| 63 | + var list = PythonEngine.Eval("list"); | ||
| 64 | + Assert.Throws<ArgumentNullException>(() => list.Invoke(new PyObject[] {null})); | ||
| 65 | + } | ||
| 60 | 66 | } | |
| 61 | 67 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -62,7 +62,7 @@ public PyInt(int value) | |||
| 62 | 62 | /// Creates a new Python int from a uint32 value. | |
| 63 | 63 | /// </remarks> | |
| 64 | 64 | [CLSCompliant(false)] | |
| 65 | - public PyInt(uint value) : base(IntPtr.Zero) | ||
| 65 | + public PyInt(uint value) | ||
| 66 | 66 | { | |
| 67 | 67 | obj = Runtime.PyInt_FromInt64(value); | |
| 68 | 68 | Runtime.CheckExceptionOccurred(); | |
@@ -75,7 +75,7 @@ public PyInt(uint value) : base(IntPtr.Zero) | |||
| 75 | 75 | /// <remarks> | |
| 76 | 76 | /// Creates a new Python int from an int64 value. | |
| 77 | 77 | /// </remarks> | |
| 78 | - public PyInt(long value) : base(IntPtr.Zero) | ||
| 78 | + public PyInt(long value) | ||
| 79 | 79 | { | |
| 80 | 80 | obj = Runtime.PyInt_FromInt64(value); | |
| 81 | 81 | Runtime.CheckExceptionOccurred(); | |
@@ -89,7 +89,7 @@ public PyInt(long value) : base(IntPtr.Zero) | |||
| 89 | 89 | /// Creates a new Python int from a uint64 value. | |
| 90 | 90 | /// </remarks> | |
| 91 | 91 | [CLSCompliant(false)] | |
| 92 | - public PyInt(ulong value) : base(IntPtr.Zero) | ||
| 92 | + public PyInt(ulong value) | ||
| 93 | 93 | { | |
| 94 | 94 | obj = Runtime.PyInt_FromInt64((long)value); | |
| 95 | 95 | Runtime.CheckExceptionOccurred(); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments