diff --git a/include/pocketpy/xmacros/magics.h b/include/pocketpy/xmacros/magics.h index f4941a2e..37f95241 100644 --- a/include/pocketpy/xmacros/magics.h +++ b/include/pocketpy/xmacros/magics.h @@ -8,7 +8,6 @@ MAGIC_METHOD(__ge__) ///////////////////////////// MAGIC_METHOD(__neg__) MAGIC_METHOD(__abs__) -MAGIC_METHOD(__int__) MAGIC_METHOD(__round__) MAGIC_METHOD(__divmod__) ///////////////////////////// diff --git a/src/public/py_number.c b/src/public/py_number.c index 164b9009..0d15781f 100644 --- a/src/public/py_number.c +++ b/src/public/py_number.c @@ -123,9 +123,7 @@ static bool number__pow__(int argc, py_Ref argv) { return true; } -static py_i64 i64_abs(py_i64 x) { - return x < 0 ? -x : x; -} +static py_i64 i64_abs(py_i64 x) { return x < 0 ? -x : x; } static py_i64 cpy11__fast_floor_div(py_i64 a, py_i64 b) { assert(b != 0); @@ -316,7 +314,7 @@ static bool int__new__(int argc, py_Ref argv) { return true; } case tp_str: break; // leave to the next block - default: return pk_callmagic(__int__, 1, argv + 1); + default: return TypeError("int() argument must be a string, number or boolean"); } } // 2+ args -> error diff --git a/tests/99_extras.py b/tests/99_extras.py index 392e0813..b6b8d9ea 100644 --- a/tests/99_extras.py +++ b/tests/99_extras.py @@ -52,13 +52,7 @@ assert A()[1:2, :A()[3:4, ::-1]] == (slice(1, 2, None), slice(None, (slice(3, 4, assert 2**2**3 == 256 assert (2**2**3)**2 == 65536 -class Number: - def __float__(self): - return 1.0 - - def __int__(self): - return 2 - +class Number: def __divmod__(self, other): return 3, 4 @@ -66,9 +60,6 @@ class Number: return args assert divmod(Number(), 0) == (3, 4) -assert float(Number()) == 1.0 -assert int(Number()) == 2 - assert round(Number()) == tuple() assert round(Number(), 1) == (1,)