mirror of
https://github.com/pocketpy/pocketpy
synced 2025-11-10 05:30:16 +00:00
raise a ZeroDivisionError when true-dividing by zero
This commit is contained in:
parent
2129392b0e
commit
1b793fd5b2
@ -372,6 +372,7 @@ void init_builtins(VM* _vm) {
|
||||
});
|
||||
_vm->bind__truediv__(VM::tp_int, [](VM* vm, PyObject* _0, PyObject* _1) {
|
||||
f64 value = CAST_F(_1);
|
||||
if (value == 0.) vm->ZeroDivisionError("division by zero");
|
||||
return VAR(_CAST(i64, _0) / value);
|
||||
});
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user