diff options
author | Ilya Mashchenko <ilya@netdata.cloud> | 2019-12-31 11:32:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-31 11:32:13 +0100 |
commit | 80f3439917393c8ec12a4951c0d3e1b4cc013433 (patch) | |
tree | 74503402c3a77a5b0ae232c9f4095d60f32f9b3e /collectors/python.d.plugin/python_modules | |
parent | 6c64f40c7f3b43dac128c74bfb321f5b4ba661c7 (diff) |
python.d logger: unicode_str handle TypeError (#7645)
* collection.py: unicode_str handle TypeError
Diffstat (limited to 'collectors/python.d.plugin/python_modules')
-rw-r--r-- | collectors/python.d.plugin/python_modules/bases/collection.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/collectors/python.d.plugin/python_modules/bases/collection.py b/collectors/python.d.plugin/python_modules/bases/collection.py index b932e3a24c..3b5b243e33 100644 --- a/collectors/python.d.plugin/python_modules/bases/collection.py +++ b/collectors/python.d.plugin/python_modules/bases/collection.py @@ -23,10 +23,11 @@ def run_and_exit(func): def wrapper(*args, **kwargs): func(*args, **kwargs) exit(1) + return wrapper -def on_try_except_finally(on_except=(None, ), on_finally=(None, )): +def on_try_except_finally(on_except=(None,), on_finally=(None,)): except_func = on_except[0] finally_func = on_finally[0] @@ -40,7 +41,9 @@ def on_try_except_finally(on_except=(None, ), on_finally=(None, )): finally: if finally_func: finally_func(*on_finally[1:]) + return wrapper + return decorator @@ -49,6 +52,7 @@ def static_vars(**kwargs): for k in kwargs: setattr(func, k, kwargs[k]) return func + return decorate @@ -94,9 +98,14 @@ def unicode_str(arg): :param arg: :return: <str> """ + # TODO: fix try: + # https://github.com/netdata/netdata/issues/7613 if isinstance(arg, unicode): return arg return unicode(arg, errors='ignore') + # https://github.com/netdata/netdata/issues/7642 + except TypeError: + return unicode(arg) except NameError: return str(arg) |