[New-bugs-announce] [issue5981] float.fromhex bugs

Mark Dickinson report at bugs.python.org
Sat May 9 21:50:17 CEST 2009

New submission from Mark Dickinson <dickinsm at gmail.com>:

Two problems with float.fromhex:

(1) it incorrectly rejects trailing whitespace on infs and nans:

>>> float.fromhex('a.0 ')
>>> float.fromhex('nan ')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: invalid hexadecimal floating-point string

(2) The implementation uses PyOS_strnicmp for detecting nans and infs,
which is locale-aware.  A locale-unaware case-insensitive comparison 
should be used instead.  I don't know of any locale where this actually 
makes a difference, but I think it should be fixed anyway.

assignee: marketdickinson
components: Interpreter Core
messages: 87509
nosy: marketdickinson
priority: normal
severity: normal
stage: needs patch
status: open
title: float.fromhex bugs
type: behavior
versions: Python 2.6, Python 2.7, Python 3.0, Python 3.1

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list