diff --git a/backoff.py b/backoff.py index e5f4a31..16bd49b 100644 --- a/backoff.py +++ b/backoff.py @@ -152,15 +152,15 @@ def constant(interval): yield interval -# Formats a function invocation as a string for logging. +# Formats a function invocation as a unicode string for logging. def _invoc_repr(f, args, kwargs): - str_args = ", ".join(str(a) for a in args) + args_out = ", ".join(unicode(a) for a in args) if args and kwargs: - str_args += ", " + args_out += ", " if kwargs: - str_args += ", ".join("%s=%s" % i for i in kwargs.items()) + args_out += ", ".join("%s=%s" % i for i in kwargs.items()) - return "%s(%s)" % (f.__name__, str_args) + return "%s(%s)" % (f.__name__, args_out) def on_predicate(wait_gen, diff --git a/backoff_tests.py b/backoff_tests.py index 519307d..c7b1b60 100644 --- a/backoff_tests.py +++ b/backoff_tests.py @@ -113,3 +113,5 @@ def func(a, b, c=None): {"c": "c"}) assert "func(c=c)" == backoff._invoc_repr(func, [], {"c": "c"}) assert "func(a, b)" == backoff._invoc_repr(func, ["a", "b"], {}) + assert u"func(ユニコーン, ア=あ)" == \ + backoff._invoc_repr(func, [u"ユニコーン"], {u"ア": u"あ"})