From: Christopher Lenz Date: Wed, 11 Jun 2008 20:00:21 +0000 (+0000) Subject: Fix handling of default value of `locales` parameter of the `Translations.load()... X-Git-Tag: 1.0~339 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=39e6dbe4e8e1232a4635f82dcd02212606e0e2d5;p=thirdparty%2Fbabel.git Fix handling of default value of `locales` parameter of the `Translations.load()` method. Thanks to Armin Ronacher for reporting the problem. --- diff --git a/babel/support.py b/babel/support.py index 2145d8fa..f0c9f0c8 100644 --- a/babel/support.py +++ b/babel/support.py @@ -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()