From: Christopher Lenz Date: Wed, 5 Sep 2007 16:40:17 +0000 (+0000) Subject: In `Locale.parse()`, only parse the argument if it's a string, otherwise just return... X-Git-Tag: 1.0~379 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9f22da49f7f06043d8c36bf5c5526abcb584cd27;p=thirdparty%2Fbabel.git In `Locale.parse()`, only parse the argument if it's a string, otherwise just return the argument. This assumes that a non-string argument is either a `Locale` instance, or a proxy object pretending to be one. That may not be a safe assumption, but at least it allows you to use proxy objects such as Paste's `StackedObjectProxy` for locales. --- diff --git a/babel/core.py b/babel/core.py index 4e8e032f..3b237cff 100644 --- a/babel/core.py +++ b/babel/core.py @@ -206,9 +206,9 @@ class Locale(object): requested locale :see: `parse_locale` """ - if type(identifier) is cls: - return identifier - return cls(*parse_locale(identifier, sep=sep)) + if isinstance(identifier, basestring): + return cls(*parse_locale(identifier, sep=sep)) + return identifier parse = classmethod(parse) def __eq__(self, other):