Skip to content

Commit dbb88bc

Browse files
authored
Added parameter validation to PyObject methods (#1021)
* added parameter validation to PyObject methods
1 parent 3362cf8 commit dbb88bc

File tree

3 files changed

+130
-15
lines changed

3 files changed

+130
-15
lines changed

src/embed_tests/TestPyObject.cs

+6
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

+3-3
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)