# HG changeset patch # User cmlenz # Date 1213214421 0 # Node ID 398e7c3771654e67556f260c4bdc564bc17338d1 # Parent 662d332c0a2b141218862cf2e19217398dae9e15 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 --- a/babel/support.py +++ b/babel/support.py @@ -276,7 +276,7 @@ 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 @@ 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()