Skip to content

Commit fb4123f

Browse files
committed
remove action
1 parent 8d74e1c commit fb4123f

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/runtime/pythonexception.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,11 +261,10 @@ internal static void ThrowIfIsNull(BorrowedReference reference)
261261
}
262262
}
263263

264-
public static void ThrowIfIsNotZero(int value, Action onBeforeThrow = null)
264+
public static void ThrowIfIsNotZero(int value)
265265
{
266266
if (value != 0)
267267
{
268-
onBeforeThrow?.Invoke();
269268
throw new PythonException();
270269
}
271270
}

src/runtime/pytuple.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,11 @@ private static IntPtr FromArray(PyObject[] items)
7474
IntPtr ptr = items[i].obj;
7575
Runtime.XIncref(ptr);
7676
int res = Runtime.PyTuple_SetItem(val, i, ptr);
77-
PythonException.ThrowIfIsNotZero(res, () => Runtime.Py_DecRef(val));
77+
if (res == 0)
78+
{
79+
Runtime.Py_DecRef(val);
80+
PythonException.ThrowIfIsNotZero(res);
81+
}
7882
}
7983
return val;
8084
}

0 commit comments

Comments
 (0)