From: benselme Date: Sun, 11 Jan 2015 23:18:12 +0000 (-0500) Subject: Fixed 2.6 bug (Decimal cannot convert floats) X-Git-Tag: dev-2a51c9b95d06~51^2^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=21d6efe915a6b41630878805fcfa06e50c601d13;p=thirdparty%2Fbabel.git Fixed 2.6 bug (Decimal cannot convert floats) --- diff --git a/babel/plural.py b/babel/plural.py index 918038e6..50bf5418 100644 --- a/babel/plural.py +++ b/babel/plural.py @@ -10,6 +10,7 @@ """ import decimal import re +import sys _plural_tags = ('zero', 'one', 'two', 'few', 'many', 'other') @@ -25,7 +26,13 @@ def extract_operands(source): n = abs(source) i = int(n) if isinstance(n, float): - n = i if i == n else decimal.Decimal(n) + if i == n: + n = i + else: + # 2.6's Decimal cannot convert from float directly + if sys.version_info < (2, 7): + n = str(n) + n = decimal.Decimal(n) if isinstance(n, decimal.Decimal): dec_tuple = n.as_tuple()