This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark.dickinson
Recipients mark.dickinson, pgimeno
Date 2021-08-19.12:29:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1629376146.62.0.213173826853.issue44954@roundup.psfhosted.org>
In-reply-to
Content
The bug is in this line:

https://github.com/python/cpython/blob/3db42fc5aca320b0cac1895bc3cb731235ede794/Objects/floatobject.c#L1467

which reads:

            (half_eps == 8 && (HEX_DIGIT(key_digit+1) & 1) != 0))

In the buggy case, key_digit=0 and the HEX_DIGIT macro is trying to retrieve the value of the second-to-least significant hex digit in the coefficient, to decide whether it's odd or not. For the "0x0.8" case it retrieves the "0". For the "0x.8" case, it retrieves the "x" and tries to interpret it as a hex digit.

Even worse, if we exclude the "0x" prefix, as in `float.fromhex(".8p-1074")`, `HEX_DIGIT(1)` is accessing memory that doesn't belong to the string.
History
Date User Action Args
2021-08-19 12:29:06mark.dickinsonsetrecipients: + mark.dickinson, pgimeno
2021-08-19 12:29:06mark.dickinsonsetmessageid: <1629376146.62.0.213173826853.issue44954@roundup.psfhosted.org>
2021-08-19 12:29:06mark.dickinsonlinkissue44954 messages
2021-08-19 12:29:06mark.dickinsoncreate