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.max(NaN, x) gives incorrect results when x is finite and long
Type: behavior Stage:
Components: Versions: Python 3.0, Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: mark.dickinson Nosy List: facundobatista, loewis, mark.dickinson
Priority: normal Keywords: patch

Created on 2008-10-09 08:43 by mark.dickinson, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
decimal_maxbug.patch mark.dickinson, 2008-10-09 08:43 Fix for this issue
Messages (6)
msg74557 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2008-10-09 08:43
Here's a snippet from Python 2.6:

>>> from decimal import Decimal, getcontext
>>> getcontext().prec = 3
>>> Decimal('NaN').max(Decimal('1234'))
Decimal('sNaN234')

The result here should be Decimal('1.23E+3')---the specification says that 
the result of comparing a quiet NaN with a finite value should be that 
finite value, rounded according to the context.

This also affects min, max_mag and min_mag.

The cause is that non-NaNs are incorrectly being passed to the _fix_nan 
method.  The attached patch fixes this, and adds new testcases to 
extra.decTest to stop it happening again.

It would be good to get this fix into 3.0, if possible.  I think it should 
also be backported to 2.5.3.
msg77518 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2008-12-10 09:08
Unless Facundo or some of the other decimal contributors reviews and
applies this patch really quickly, it is out of scope for 2.5.3.
msg77589 - (view) Author: Facundo Batista (facundobatista) * (Python committer) Date: 2008-12-11 04:21
Commited in trunk and Py3, thanks Mark!

Please, could you commit it in 2.5? The only change I've made in the
patch is adding the issue number to Misc/NEWS, the rest is ok.

After that, just close this.

Thanks again!
msg77594 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2008-12-11 06:41
Mark, if you want to backport this, please go ahead. If want me to,
assign to me.
msg77600 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2008-12-11 09:10
Committed, r67699.  Thanks!

Leaving open because I still need to merge this to the 3.0 and 2.6 
maintenance branches.
msg77601 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2008-12-11 09:25
Merged to 2.6 and 3.0 maintenance branches (r67700, r67701).
History
Date User Action Args
2022-04-11 14:56:40adminsetgithub: 48334
2008-12-11 09:25:20mark.dickinsonsetstatus: open -> closed
resolution: fixed
messages: + msg77601
2008-12-11 09:10:56mark.dickinsonsetpriority: release blocker -> normal
messages: + msg77600
versions: + Python 2.6, Python 3.0, - Python 2.5.3
2008-12-11 06:41:20loewissetpriority: normal -> release blocker
assignee: facundobatista -> mark.dickinson
messages: + msg77594
2008-12-11 04:21:45facundobatistasetmessages: + msg77589
versions: - Python 2.6, Python 3.0, Python 3.1, Python 2.7
2008-12-10 09:08:05loewissetnosy: + loewis
messages: + msg77518
2008-12-06 18:31:08mark.dickinsonsetversions: + Python 3.1
2008-10-09 08:43:17mark.dickinsoncreate