From ba3dce971fae5a4f3a79be8b34df03bfcf5b9070 Mon Sep 17 00:00:00 2001 From: Ultrabug Date: Sun, 23 Jun 2013 23:32:58 +0200 Subject: fix instancemethod detection wrt issue #11 thx to @lathan and @bloodred, inspired by pull request #12 by @drahier --- py3status/__init__.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'py3status') diff --git a/py3status/__init__.py b/py3status/__init__.py index ad8b699..6dd7269 100755 --- a/py3status/__init__.py +++ b/py3status/__init__.py @@ -292,16 +292,14 @@ class UserModules(Thread): self.classes[f_name] = (class_inst, []) self.cache[f_name] = {} for method in dir(class_inst): - # ignore private methods - if '_Py3status' in method: + # exclude private and other decorated methods + # such as @property or @staticmethod + if method.startswith('_'): continue - try: - cl = eval("class_inst.%s.im_class" % method) - if 'Py3status' in str(cl): + else: + m_type = type(getattr(class_inst, method)) + if 'method' in str(m_type): self.classes[f_name][1].append(method) - except: - # ignore non Py3status-wide methods - pass except Exception: err = sys.exc_info()[1] syslog(LOG_ERR, "loading %s failed (%s)" \ -- cgit v1.3