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" >>> 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. ---------- assignee: facundobatista components: Library (Lib) messages: 59642 nosy: facundobatista, marketdickinson priority: normal severity: minor status: open title: Decimal constructor accepts newline terminated strings type: behavior versions: Python 2.5, Python 2.6, Python 3.0 __________________________________ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue1780> __________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com