Skip to content

Commit

Permalink
added a few debug checks
Browse files Browse the repository at this point in the history
  • Loading branch information
lostmsu committed Apr 11, 2021
1 parent 57525cd commit 87dd9fd
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/runtime/runtime.cs
Expand Up @@ -1128,13 +1128,31 @@ internal static int PyObject_Compare(IntPtr value1, IntPtr value2)
internal static nint PyObject_Hash(IntPtr op) => Delegates.PyObject_Hash(op);


internal static IntPtr PyObject_Repr(IntPtr pointer) => Delegates.PyObject_Repr(pointer);
internal static IntPtr PyObject_Repr(IntPtr pointer)
{
AssertNoErorSet();

return Delegates.PyObject_Repr(pointer);
}

internal static IntPtr PyObject_Str(IntPtr pointer) => Delegates.PyObject_Str(pointer);


internal static IntPtr PyObject_Unicode(IntPtr pointer) => Delegates.PyObject_Unicode(pointer);
internal static IntPtr PyObject_Unicode(IntPtr pointer)
{
AssertNoErorSet();

return Delegates.PyObject_Unicode(pointer);
}

[Conditional("DEBUG")]
internal static void AssertNoErorSet()
{
if (Exceptions.ErrorOccurred())
throw new InvalidOperationException(
"Can't call with exception set",
PythonException.FetchCurrent());
}


internal static IntPtr PyObject_Dir(IntPtr pointer) => Delegates.PyObject_Dir(pointer);
Expand Down

0 comments on commit 87dd9fd

Please sign in to comment.