-
-
Notifications
You must be signed in to change notification settings - Fork 33.3k
Open
Labels
3.14bugs and security fixesbugs and security fixes3.15new features, bugs and security fixesnew features, bugs and security fixesextension-modulesC modules in the Modules dirC modules in the Modules dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
import struct
f = struct.unpack(">d", bytes.fromhex("7FF0000000080001"))[0]
print(f) # nan
f2 = struct.unpack(">f", struct.pack(">f", f))[0]
print(f2) # infRepeating this with FFF0000000080001 you'll see nan turn into -inf.
This only happens in Python 3.14+ (not 3.13). I'm pretty sure that this fix is causing it: #130317
Preserving the signaling/quieting bit is a great idea, I find. But since the mantissa is being truncated, one must ensure that the narrower width mantissa doesn't end up being all 0 bits as that represents inf instead of nan.
CPython versions tested on:
3.14
Operating systems tested on:
Linux
Linked PRs
Metadata
Metadata
Assignees
Labels
3.14bugs and security fixesbugs and security fixes3.15new features, bugs and security fixesnew features, bugs and security fixesextension-modulesC modules in the Modules dirC modules in the Modules dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error