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.

classification
Title: math.isfinite fails with Decimal sNAN
Type: behavior Stage: resolved
Components: Documentation, Library (Lib) Versions: Python 3.4
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: docs@python Nosy List: BreamoreBoy, docs@python, facundobatista, mark.dickinson, rhettinger, skrah, steven.daprano
Priority: normal Keywords:

Created on 2013-08-26 15:38 by steven.daprano, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (4)
msg196213 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2013-08-26 15:38
math.isfinite currently raises ValueError when given a Decimal sNAN (signalling NAN).

I've run into a situation where I'm calling isfinite() on a numeric value which may be a Decimal sNAN, and it would be nice if it returned False.

On the other hand, see the discussion on issue 15544, which possibly leads to the conclusion that raising ValueError is the right thing to do.

http://bugs.python.org/issue15544

Either way, behaviour should be documented.
msg224662 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-08-03 20:58
Steven, can you propose a patch for this?
msg224928 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2014-08-06 12:18
Mark: it's not really ready for a patch, since there's no agreement yet on how best to solve this.  In fact, I'm tempted to close as "wont fix": the argument is that the math module consists for the most part only of thin wrappers around the platform math library.

The underlying need (as far as I understand it) is to be able to tell whether a given number is a nan or not without having to know in advance whether it's a float, int or Decimal instance.  There may be other ways of achieving this goal (like adding an `is_nan` method to `float` and `int`, for example.)
msg229309 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2014-10-14 16:13
"Wont fix" sounds good to me.
History
Date User Action Args
2022-04-11 14:57:50adminsetgithub: 63041
2016-05-06 12:35:27berker.peksagsetstatus: open -> closed
resolution: wont fix
stage: resolved
2014-10-14 16:13:29skrahsetmessages: + msg229309
2014-08-06 12:18:12mark.dickinsonsetmessages: + msg224928
2014-08-03 20:58:22BreamoreBoysetnosy: + BreamoreBoy
messages: + msg224662
2013-08-26 17:45:48serhiy.storchakasetnosy: + rhettinger, facundobatista, mark.dickinson, skrah
2013-08-26 15:38:40steven.dapranocreate