[New-bugs-announce] [issue5829] float('1e500') -> inf, complex('1e500') -> ValueError

Mark Dickinson report at bugs.python.org
Fri Apr 24 14:26:21 CEST 2009

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

In (for example) Python 2.6:

>>> float('1e500')
>>> complex('1e500')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: float() out of range: 1e500

I'd say that one of these is a bug, but I'm not sure which one.

Ideally, float('1e500') would raise OverflowError (not ValueError).  But 
it's quite likely that there are people who depend on the current 
behaviour, and the current behaviour also agrees with what happens for 
float literals:

>>> 1e500

For 2.7 and 3.1, I propose fixing the complex constructor so that 
complex('1e500') produces (inf+0j).  For 2.6 and 3.0, I propose leaving 
the current behaviour as it is.

messages: 86402
nosy: marketdickinson
severity: normal
stage: test needed
status: open
title: float('1e500') -> inf, complex('1e500') -> ValueError
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