]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
Fix handling of default value of `locales` parameter of the `Translations.load()...
authorChristopher Lenz <cmlenz@gmail.com>
Wed, 11 Jun 2008 20:00:21 +0000 (20:00 +0000)
committerChristopher Lenz <cmlenz@gmail.com>
Wed, 11 Jun 2008 20:00:21 +0000 (20:00 +0000)
babel/support.py

index 2145d8fa9ebbc10716a6c3c3db3b9816b9d65edf..f0c9f0c8f1f5daa12ac998ae577d7cfdfffb6a5c 100644 (file)
@@ -276,7 +276,7 @@ class Translations(gettext.GNUTranslations):
                         from
         """
         gettext.GNUTranslations.__init__(self, fp=fileobj)
-        self.files = [getattr(fileobj, 'name')]
+        self.files = filter(None, [getattr(fileobj, 'name', None)])
 
     def load(cls, dirname=None, locales=None, domain=DEFAULT_DOMAIN):
         """Load translations from the given directory.
@@ -290,9 +290,10 @@ class Translations(gettext.GNUTranslations):
                  matching translations were found
         :rtype: `Translations`
         """
-        if not isinstance(locales, (list, tuple)):
-            locales = [locales]
-        locales = [str(locale) for locale in locales]
+        if locales is not None:
+            if not isinstance(locales, (list, tuple)):
+                locales = [locales]
+            locales = [str(locale) for locale in locales]
         filename = gettext.find(domain or cls.DEFAULT_DOMAIN, dirname, locales)
         if not filename:
             return gettext.NullTranslations()