[Python-Dev] Decimal(unicode)

Oleg Broytmann phd at phd.pp.ru
Tue Mar 25 16:38:25 CET 2008


On Tue, Mar 25, 2008 at 10:47:42AM -0400, Mark Dickinson wrote:
> On Tue, Mar 25, 2008 at 9:46 AM, Oleg Broytmann <phd at phd.pp.ru> wrote:
> >    In 2.5.2 it prints
> >
> >  <type 'str'>
> >  <type 'unicode'>
> >
> >    Why the change? Is it a bug or a feature? Shouldn't .to_eng_string()
> >  always return a str?
> 
> I'd call this a bug.  The change is an accident, a side-effect of the fact
> that in 2.5.1 the coefficient (mantissa) of a Decimal was stored as a
> tuple, and in 2.5.2 it's stored as a string (which greatly improves efficiency).
> Clearly in 2.5.2 the mantissa is being stored as a unicode instance in the
> second case;  it should be explicitly coerced to str in Decimal.__new__.
> 
> If others agree that it's a bug, I'll fix it.

http://bugs.python.org/issue2482

Oleg.
-- 
     Oleg Broytmann            http://phd.pp.ru/            phd at phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.


More information about the Python-Dev mailing list