Change in Decimal repr in Python 2.6

Karen Tracey kmtracey at gmail.com
Fri Jul 18 17:30:30 EDT 2008


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.

Thanks for any feedback,
Karen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080718/9aa3e007/attachment.html>


More information about the Python-list mailing list