[New-bugs-announce] [issue1780] Decimal constructor accepts newline terminated strings
report at bugs.python.org
Thu Jan 10 02:01:46 CET 2008
New submission from Mark Dickinson:
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"
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.
components: Library (Lib)
nosy: facundobatista, marketdickinson
title: Decimal constructor accepts newline terminated strings
versions: Python 2.5, Python 2.6, Python 3.0
Tracker <report at bugs.python.org>
More information about the New-bugs-announce