This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark.dickinson
Recipients mark.dickinson, priska
Date 2015-06-07.19:58:34
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1433707114.59.0.984217137899.issue24403@psf.upfronthosting.co.za>
In-reply-to
Content
The old behaviour certainly can be emulated, but doing that correctly would require 4 or 5 lines of code.  I don't know enough about 2to3 to know whether it can handle that sort of translation, but even if it can, I'd guess that in a good proportion of cases the loss in readability (and possibly also in performance) wouldn't be worth it, and in many cases the difference in behaviour may not matter either.  Given all that, I think it's probably better left as a judgement call on the part of the person doing the 2-to-3 porting.

Here's a translation that's immune from the two issues I pointed out.

    def round_ties_away_from_zero(x):
        n = round(x)
        if abs(x - n) == 0.5:   # x - n is exact; no rounding error
            return x + copysign(0.5, x)
        else:
            return float(n)
History
Date User Action Args
2015-06-07 19:58:34mark.dickinsonsetrecipients: + mark.dickinson, priska
2015-06-07 19:58:34mark.dickinsonsetmessageid: <1433707114.59.0.984217137899.issue24403@psf.upfronthosting.co.za>
2015-06-07 19:58:34mark.dickinsonlinkissue24403 messages
2015-06-07 19:58:34mark.dickinsoncreate