[New-bugs-announce] [issue22951] unexpected return from float.__repr__() for inf, -inf, nan
jaebae17
report at bugs.python.org
Wed Nov 26 20:47:16 CET 2014
New submission from jaebae17:
The help page for the built-in repr() states ''' For many types, this function makes an attempt to return a string that would yield an object with the same value when passed to eval()...'''
This holds true for non-inf/nan values of float():
>>> eval(repr(float('0.0')))
0.0
But for inf, -inf, and nan it does not:
>>> eval(repr(float('inf')))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 1, in <module>
NameError: name 'inf' is not defined
Expected return from repr(float('inf')) was "float('inf')", but perhaps 'inf' response has too much history at this point to be changed.
----------
messages: 231724
nosy: jaebae17
priority: normal
severity: normal
status: open
title: unexpected return from float.__repr__() for inf, -inf, nan
type: behavior
versions: Python 2.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22951>
_______________________________________
More information about the New-bugs-announce
mailing list