>>> import struct
>>> struct.pack('f', 1e300)
Traceback (most recent call last):
File "<python-input-10>", line 1, in <module>
struct.pack('f', 1e300)
~~~~~~~~~~~^^^^^^^^^^^^
OverflowError: float too large to pack with f format
>>> struct.pack('Zf', 1e300)
b'\x00\x00\x80\x7f\x00\x00\x00\x00'
>>> struct.unpack('Zf', _)
((inf+0j),)
>>> struct.pack('<Zf', 1e300) # le box, we fallback to memcpy()
b'\x00\x00\x80\x7f\x00\x00\x00\x00'
>>> struct.pack('>Zf', 1e300)
Traceback (most recent call last):
File "<python-input-14>", line 1, in <module>
struct.pack('>Zf', 1e300)
~~~~~~~~~~~^^^^^^^^^^^^^^
OverflowError: float too large to pack with f format
Bug report
Bug description:
This is similar to that issue with 'f' format type.
Consider:
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs