]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
Fixed a regression in the pluralization support
authorArmin Ronacher <armin.ronacher@active-4.com>
Sat, 6 Jul 2013 16:20:06 +0000 (18:20 +0200)
committerArmin Ronacher <armin.ronacher@active-4.com>
Sat, 6 Jul 2013 16:20:06 +0000 (18:20 +0200)
babel/plural.py

index 6e3d274ddf046d9001f88400309fe65ae712de15..c3137dbf33f04804000a9d614f8fdb6523098e6f 100644 (file)
@@ -166,7 +166,9 @@ def to_python(rule):
     to_python = _PythonCompiler().compile
     result = ['def evaluate(n):']
     for tag, ast in PluralRule.parse(rule).abstract:
-        result.append(' if (%s): return %r' % (to_python(ast), tag))
+        # the str() call is to coerce the tag to the native string.  It's
+        # a limited ascii restricted set of tags anyways so that is fine.
+        result.append(' if (%s): return %r' % (to_python(ast), str(tag)))
     result.append(' return %r' % _fallback_tag)
     code = compile('\n'.join(result), '<rule>', 'exec')
     eval(code, namespace)