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: decimal.py: NaN payload conversion
Type: Stage:
Components: Versions:
process
Status: closed Resolution: duplicate
Dependencies: Superseder: decimal.py: use DivisionImpossible and DivisionUndefined
View: 7046
Assigned To: Nosy List: mark.dickinson, skrah
Priority: normal Keywords:

Created on 2009-10-03 13:46 by skrah, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg93491 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2009-10-03 13:46
decimal.py sets InvalidOperation if the payload of a NaN is too large:

>>> c = getcontext()
>>> c.prec = 4
>>> c.create_decimal("NaN12345")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/decimal.py", line 3797, in create_decimal
    "diagnostic info too long in NaN")
  File "/usr/lib/python2.7/decimal.py", line 3733, in _raise_error
    raise error(explanation)
decimal.InvalidOperation: diagnostic info too long in NaN


decNumber (and fastdec) set ConversionSyntax.
msg93497 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2009-10-03 15:30
This is essentially the same issue as issue 7046:  the relevant lines in 
decimal.py read:

    if d._isnan() and len(d._int) > self.prec - self._clamp:
        return self._raise_error(ConversionSyntax,
                                     "diagnostic info too long in NaN")

and again, the Context._raise_error method translates the 
ConversionSyntax exceptional condition to the corresponding 
InvalidOperation signal.

Closing as a duplicate, just so we can keep everything one place.
History
Date User Action Args
2022-04-11 14:56:53adminsetgithub: 51296
2009-10-03 15:30:52mark.dickinsonsetstatus: open -> closed
resolution: duplicate
superseder: decimal.py: use DivisionImpossible and DivisionUndefined
messages: + msg93497
2009-10-03 13:47:29skrahsetnosy: + mark.dickinson
2009-10-03 13:46:46skrahcreate