From 9b0256e2b3d70b2c4d529cb8888d73a1538000cc Mon Sep 17 00:00:00 2001 From: Vitja Makarov Date: Sat, 24 Aug 2013 00:12:13 +0400 Subject: Fix NullCallableString() when called with no or multiple arguments --- blessings/__init__.py | 8 +++++--- 1 file 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): -- cgit v1.2.1