[issue18841] math.isfinite fails with Decimal sNAN

New submission from Steven D'Aprano: 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. ---------- assignee: docs@python components: Documentation, Library (Lib) messages: 196213 nosy: docs@python, stevenjd priority: normal severity: normal status: open title: math.isfinite fails with Decimal sNAN type: behavior versions: Python 3.4 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18841> _______________________________________

Changes by Serhiy Storchaka <storchaka@gmail.com>: ---------- nosy: +facundobatista, mark.dickinson, rhettinger, skrah _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18841> _______________________________________

Mark Lawrence added the comment: Steven, can you propose a patch for this? ---------- nosy: +BreamoreBoy _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18841> _______________________________________

Mark Dickinson added the comment: 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.) ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18841> _______________________________________

Stefan Krah added the comment: "Wont fix" sounds good to me. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18841> _______________________________________

Changes by Berker Peksag <berker.peksag@gmail.com>: ---------- resolution: -> wont fix stage: -> resolved status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18841> _______________________________________
participants (6)
-
Berker Peksag
-
Mark Dickinson
-
Mark Lawrence
-
Serhiy Storchaka
-
Stefan Krah
-
Steven D'Aprano