Issue 5829: float('1e500') -> inf, complex('1e500') -> ValueError (original) (raw)

Created on 2009-04-24 12:26 by mark.dickinson, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue5829.patch mark.dickinson,2009-05-16 08:24
Messages (6)
msg86402 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2009-04-24 12:26
In (for example) Python 2.6: >>> float('1e500') inf >>> complex('1e500') Traceback (most recent call last): File "", line 1, in 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 inf 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.
msg86403 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2009-04-24 12:28
Note: complex('1e-500') also produces ValueError in 2.6. That's definitely a bug.
msg86505 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2009-04-25 13:29
complex('1e-500') bug fixed in r71891 (2.6) and r71892 (3.0). It's already gone in trunk and py3k. What's left is deciding whether the OverflowError that 2.7 and 3.1 currently produce should disappear in favour of producing infinities instead.
msg87861 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2009-05-16 08:24
Patch against py3k. If someone can review this I'll apply it for 3.1; otherwise, it can wait until 3.2.
msg88002 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2009-05-17 20:55
It looks good to me.
msg88132 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2009-05-20 18:45
Thanks, Eric. Committed in r72803; backported to trunk in r72805.
History
Date User Action Args
2022-04-11 14:56:48 admin set github: 50079
2009-05-20 18:45:10 mark.dickinson set status: open -> closedresolution: fixedmessages: +
2009-05-17 20:55:41 eric.smith set nosy: + eric.smithmessages: +
2009-05-16 08:25:27 mark.dickinson set components: + Interpreter Core
2009-05-16 08:24:51 mark.dickinson set files: + issue5829.patchpriority: normalversions: - Python 2.6, Python 3.0messages: + keywords: + patchstage: test needed -> commit review
2009-05-01 15:24:15 mark.dickinson set assignee: mark.dickinson
2009-04-25 13:29:29 mark.dickinson set messages: +
2009-04-24 12:28:06 mark.dickinson set messages: +
2009-04-24 12:26:47 mark.dickinson set keywords: + easy
2009-04-24 12:26:20 mark.dickinson create