Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/embed_tests/TestPyObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,13 @@ public void AsManagedObjectInvalidCast()
var list = PythonEngine.Eval("list");
Assert.Throws<InvalidCastException>(() => list.AsManagedObject(typeof(int)));
}

[Test]
public void UnaryMinus_ThrowsOnBadType()
{
dynamic list = new PyList();
var error = Assert.Throws<PythonException>(() => list = -list);
Assert.AreEqual("TypeError", error.Type.Name);
}
}
}
2 changes: 2 additions & 0 deletions src/runtime/pyobject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1398,6 +1398,7 @@ public override bool TryBinaryOperation(BinaryOperationBinder binder, object arg
result = null;
return false;
}
Exceptions.ErrorCheck(res);
result = CheckNone(new PyObject(res));
return true;
}
Expand Down Expand Up @@ -1450,6 +1451,7 @@ public override bool TryUnaryOperation(UnaryOperationBinder binder, out object r
result = null;
return false;
}
Exceptions.ErrorCheck(res);
result = CheckNone(new PyObject(res));
return true;
}
Expand Down