Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
Open
Description
Bug report
Bug description:
Themath.log
function has a special path for integers that only works for the builtinint
type:
Lines 2220 to 2223 inac61d58
loghelper(PyObject*arg,double (*func)(double)) | |
{ | |
/* If it is int, do it ourselves. */ | |
if (PyLong_Check(arg)) { |
That means that it does not work for 3rd party integer types e.g.:
In [9]:n=gmpy2.mpz(10)**1000In [10]:math.log(int(n))Out[10]:2302.585092994045In [12]:math.log(operator.index(n))Out[12]:2302.585092994045In [11]:math.log(n)---------------------------------------------------------------------------OverflowErrorTraceback (mostrecentcalllast)CellIn[11],line1---->1math.log(n)OverflowError:'mpz'toolargetoconverttofloat
Maybe if there is a special integer handling path inmath.log
it should check for__index__
before__float__
.
Relatedgh-106502 is aboutmath.log
withDecimal
.
CPython versions tested on:
3.13
Operating systems tested on:
No response