Change in Decimal repr in Python 2.6

Terry Reedy tjreedy at udel.edu
Fri Jul 18 22:12:45 EDT 2008



Karen Tracey wrote:
> I noticed when trying out Python's 2.6b2 release that the repr of 
> Decimal has changed since 2.5.  On 2.5:
> 
> Python 2.5.1 (r251:54863, Mar  7 2008, 04:10:12)
> [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>  >>> import decimal
>  >>> decimal.Decimal(7)
> Decimal("7")
>  >>>
> 
> double quotes were used whereas on 2.6b2:
> 
> Python 2.6b2 (r26b2:65082, Jul 18 2008, 13:36:54)
> [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>  >>> import decimal
>  >>> decimal.Decimal(7)
> Decimal('7')
>  >>>
> 
> single quotes are used.  Searching around I see this was done in r60773 
> with the log message:
> 
> Fix decimal repr which should have used single quotes like other reprs.
> 
> but I can't find any discussion other than that. 
> 
> My problem is this breaks a bunch of doctests that were written assuming 
> the prior repr.  I can't just update the tests to assume the new single 
> quotes because they are for code that is supposed to run on everything 
> back to Python 2.3. 
> 
> So my question:
> 
> Is this backwards-incompatible change really necessary and could it be 
> reconsidered?
> If it's here to stay, is there some straightforward why that I am 
> unaware of to construct tests that use Decimal repr but will work 
> correctly on Python 2.3-2.6?
> 
> Also, if this is not the right list for this question please let me know 
> where would be more appropriate and I will go there.

If answers here do not satisfy, the pydev list would be the place to 
request that this change be put off until 3.0, when changes that break 
are more permissible.  I do not remember any discussion of this issue. 
You can also post there via news.gmane.org/g.c.python.devel (the mail to 
news gateway).




More information about the Python-list mailing list