Bug report
Bug description:
Other _Py_* helpers in the complexobject.c - only set errno on errors, assuming that it was set to 0 prior to the function call. This is not the case for _Py_c_abs().
So, it's possible to trigger OverflowError in abs() for nan's input:
$ cat a.py
import _testcapi
z = complex('nan')
_testcapi.set_errno(34)
abs(z)
$ ./python a.py
Traceback (most recent call last):
File "/home/sk/src/cpython/a.py", line 4, in <module>
abs(z)
~~~^^^
OverflowError: absolute value too large
Credits for @devdanzin for discovery.
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs
Bug report
Bug description:
Other
_Py_*helpers in the complexobject.c - only set errno on errors, assuming that it was set to 0 prior to the function call. This is not the case for_Py_c_abs().So, it's possible to trigger OverflowError in abs() for nan's input:
Credits for @devdanzin for discovery.
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs