Bug report
Bug description:
Consider this:
>>> import array
>>> a = array.array('e', [123])
>>> a[0] = 123456 # doesn't fit in _Float16 but fits in _Float32
Traceback (most recent call last):
File "<python-input-5>", line 1, in <module>
a[0] = 123456
~^^^
OverflowError: float too large to pack with e format
>>> a
array('e', [123.0])
>>> a[0] = 1e300 # doesn't fit neither in _Float32 nor in _Float16
>>> a
array('e', [inf])
That's happened because we use PyArg_Parse() function with 'f' format code to parse floats. Then in the second case PyFloat_Pack2() seen plain infinity and doesn't trigger overflow.
I believe both examples should trigger overflows.
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs
Reactions are currently unavailable
Bug report
Bug description:
Consider this:
That's happened because we use PyArg_Parse() function with 'f' format code to parse floats. Then in the second case PyFloat_Pack2() seen plain infinity and doesn't trigger overflow.
I believe both examples should trigger overflows.
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs