From 93e28aa20c9333ba741546ac84fb5126ff835f8d Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Thu, 20 Sep 2007 18:39:09 -0400 Subject: [PATCH] Allow decorator to work on stuff that's not a declared method or function. --- src/decorator.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/decorator.py b/src/decorator.py index 6b0bbef..eaf0b7b 100644 --- a/src/decorator.py +++ b/src/decorator.py @@ -81,6 +81,10 @@ def update_wrapper(wrapper, wrapped, create=False): # the real meat is here def _decorator(caller, func): + if not (inspect.ismethod(func) or inspect.isfunction(func)): + # skip all the fanciness, just do what works + return lambda *args, **kwargs: caller(func, *args, **kwargs) + infodict = getinfo(func) argnames = infodict['argnames'] assert not ('_call_' in argnames or '_func_' in argnames), \ -- GitLab