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: Potential Bug in mpdecimal.c
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.3
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Ken.Cheung, mark.dickinson, skrah
Priority: normal Keywords:

Created on 2012-06-19 15:59 by Ken.Cheung, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
mpdecimal_clone.txt Ken.Cheung, 2012-06-19 15:59
Messages (4)
msg163185 - (view) Author: Ken Cheung (Ken.Cheung) Date: 2012-06-19 15:59
I observed a code clone from the following files.

function : mpd_qexp @ (file: "Python-3.3.0a4/Modules/_decimal/libmpdec/mpdecimal.c", line: 4092)~4165
function : mpd_qln @ (file: "Python-3.3.0a4/Modules/_decimal/libmpdec/mpdecimal.c", line: 4525)~4612

In the first few lines of this clone, the function mpd_qexp only calls mpd_setspecial when mpd_isnegative is false while the function mpd_qln calls mpd_setspecial independent of the value of mpd_isnegative. I wonder the checking is necessary in the function mpd_qln. The source code is included in the attachment. Hope it helps.
msg163189 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2012-06-19 16:15
The code looks fine to me.

> In the first few lines of this clone, the function mpd_qexp only calls 
> mpd_setspecial when mpd_isnegative is false while the function mpd_qln 
> calls mpd_setspecial independent of the value of mpd_isnegative.

That would probably be because exp(-infinity) is 0, which isn't a floating-point special value, and ln(-infinity) is NaN, which is.

In general, I don't think this kind of report is terribly helpful unless you've also examined *and understood* the code, and based on that understanding you've established that there's a high likelihood of a real bug.
msg163190 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2012-06-19 16:20
> That would probably be because exp(-infinity) is 0, which isn't a
> floating-point special value, and ln(-infinity) is NaN, which is.

Actually, looking at the code, mpd_setspecial is called under exactly the same circumstances (namely for +inf) in *both* cases; for -inf, the exp code calls _settriple, while the ln code calls mpd_seterror.
msg163277 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2012-06-20 14:05
Mark has already said it all. -- Ken, I want to add that in the case
of _decimal it's pretty easy to test any suspected misbehavior against
decimal.py. This would have shown very quickly that there is no bug.
History
Date User Action Args
2022-04-11 14:57:31adminsetgithub: 59312
2012-06-20 14:05:42skrahsetmessages: + msg163277
2012-06-19 16:20:07mark.dickinsonsetmessages: + msg163190
2012-06-19 16:15:18mark.dickinsonsetstatus: open -> closed

nosy: + mark.dickinson, skrah
messages: + msg163189

resolution: not a bug
2012-06-19 15:59:21Ken.Cheungcreate