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.

Author mark.dickinson
Recipients facundobatista, mark.dickinson
Date 2008-01-10.01:01:44
SpamBayes Score 0.050446793
Marked as misclassified No
Message-id <1199926906.81.0.101046326746.issue1780@psf.upfronthosting.co.za>
In-reply-to
Content
After seeing issue #1761, I realized that there's a bug in the Decimal 
constructor:  it accepts newline-terminated strings:

>>> from decimal import *
>>> s = "2.3\n"
>>> Decimal(s)
Decimal("2.3")

I think this is, strictly speaking, a bug because:

(1) The IBM decimal specification explicitly disallows additional whitespace 
in a numeric string (see http://www2.hursley.ibm.com/decimal/daconvs.html),

(2) the operation to-number is supposed only to accept numeric strings, and

(3) Decimal.__new__ is currently the method that implements to-number.

Is this worth fixing?  This buggy behaviour might well be useful (e.g. to 
someone parsing a file with one Decimal per line).

I'll fix it if anyone thinks it's worth it.  Even if it should be fixed, I 
don't think this is worth backporting to Python 2.5, especially since it 
might break things.
History
Date User Action Args
2008-01-10 01:01:46mark.dickinsonsetspambayes_score: 0.0504468 -> 0.050446793
recipients: + mark.dickinson, facundobatista
2008-01-10 01:01:46mark.dickinsonsetspambayes_score: 0.0504468 -> 0.0504468
messageid: <1199926906.81.0.101046326746.issue1780@psf.upfronthosting.co.za>
2008-01-10 01:01:45mark.dickinsonlinkissue1780 messages
2008-01-10 01:01:44mark.dickinsoncreate