[issue2531] float compared to decimal is silently incorrect.

Mark Dickinson report at bugs.python.org
Sun Jan 24 13:37:22 CET 2010


Mark Dickinson <dickinsm at gmail.com> added the comment:

Stefan:  the problem is backwards compatibility.  In 2.6 it's possible to sort a heterogeneous list that contains both Decimal instances and floats.  The resulting order may not be particularly meaningful, but for some applications that doesn't matter.

If we make a Decimal-to-float comparison raise TypeError for 2.7 then sort will raise a TypeError where it used to work, so it's a potential code-breaking change.  We could deprecate:  raise a warning in 2.7 and make it a TypeError in 2.8, but since 2.8 currently seems unlikely to happen that would be a bit pointless.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue2531>
_______________________________________


More information about the Python-bugs-list mailing list