Skip to content

Commit 0acc47a

Browse files
committed
fix bug where converting a UInt32 doesn't raise an OverflowError
1 parent bc932a3 commit 0acc47a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pythonnet/src/runtime/converter.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,14 @@ static bool ToPrimitive(IntPtr value, Type obType, out Object result,
540540
if (Exceptions.ErrorOccurred()) {
541541
goto overflow;
542542
}
543+
544+
IntPtr check = Runtime.PyLong_FromUnsignedLong(ui);
545+
int err = Runtime.PyObject_Compare(check, op);
546+
Runtime.Decref(check);
547+
if (0 != err || Exceptions.ErrorOccurred()) {
548+
goto overflow;
549+
}
550+
543551
result = ui;
544552
return true;
545553

0 commit comments

Comments
 (0)