changeset 393:dd0df1242ae3

Fixed a bug in plural.py that caused a traceback for some locales, changed the `__mod__` DateTimePattern to not raise exceptions but return NotImplemented.
author aronacher
date Mon, 14 Jul 2008 22:18:39 +0000
parents 34c0a25b1ed7
children afa3582f7e1f
files babel/dates.py babel/plural.py
diffstat 2 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/babel/dates.py
+++ b/babel/dates.py
@@ -731,7 +731,8 @@
         return self.pattern
 
     def __mod__(self, other):
-        assert type(other) is DateTimeFormat
+        if type(other) is not DateTimeFormat:
+            return NotImplemented
         return self.format % other
 
     def apply(self, datetime, locale):
--- a/babel/plural.py
+++ b/babel/plural.py
@@ -351,7 +351,7 @@
     def expr(self):
         self.expect('word', 'n')
         if self.skip('word', 'mod'):
-            return 'mod', (('n', None), self.value())
+            return 'mod', (('n', ()), self.value())
         return 'n', ()
 
     def value(self):
Copyright (C) 2012-2017 Edgewall Software