diff options
author | Vitja Makarov <vitja.makarov@gmail.com> | 2013-08-24 00:12:13 +0400 |
---|---|---|
committer | Vitja Makarov <vitja.makarov@gmail.com> | 2013-08-24 00:12:13 +0400 |
commit | 9b0256e2b3d70b2c4d529cb8888d73a1538000cc (patch) | |
tree | 1acfe9057a16beb914efad74b63313120f551b32 | |
parent | 74e89a57be025df0afee92eb1aa105ec786b2356 (diff) | |
download | blessings-9b0256e2b3d70b2c4d529cb8888d73a1538000cc.tar.gz |
Fix NullCallableString() when called with no or multiple arguments
-rw-r--r-- | blessings/__init__.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/blessings/__init__.py b/blessings/__init__.py index 276565b..5efcb0b 100644 --- a/blessings/__init__.py +++ b/blessings/__init__.py @@ -453,10 +453,12 @@ class NullCallableString(unicode): new = unicode.__new__(cls, u'') return new - def __call__(self, arg): - if isinstance(arg, int): + def __call__(self, *args): + if len(args) != 1: + return u'' + if isinstance(args[0], int): return u'' - return arg # TODO: Force even strs in Python 2.x to be unicodes? Nah. How would I know what encoding to use to convert it? + return args[0] # TODO: Force even strs in Python 2.x to be unicodes? Nah. How would I know what encoding to use to convert it? def split_into_formatters(compound): |