Mark Dickinson added the comment: In the spirit of making the Decimal constructor match the rest of the language, can I propose another change: make Decimal("not a decimal") raise a ValueError.
Currently, Decimal("not a decimal") either raises InvalidOperation or returns a Decimal NaN, depending on whether the InvalidOperation trap is set in the current context or not. This behaviour presumably again comes directly from the specification, but as pointed out already Decimal.__new__ doesn't need to rigidly follow the specification---we just need to make sure that the functionality of to-number is present somewhere (and create_decimal seems like a good candidate for that). It seems to me that: Decimal.__new__ shouldn't care about the current context. The fact that __new__ takes a context parameter at the moment is potentially confusing: one might reasonably expect that passing a context to __new__ would result in the Decimal being rounded to fit that context (as happens with create_decimal). In fact, the *only* reason the context argument is there because it's needed to raise InvalidOperation; if the first argument to __new__ is valid then the context is entirely unused. __________________________________ 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