Return the function again from the hook decorator

The decorator variant of hook registration did not return anything,
meaning that the decorated function would end up being `None`. This was
not noticed, as the functions are rarely called manually, as opposed to
being invoked via the hook.
This commit is contained in:
Tim Heap 2014-07-15 16:09:11 +10:00
parent 59966b5385
commit edd8ac2d77

View file

@ -25,7 +25,10 @@ def register(hook_name, fn=None):
# Pretend to be a decorator if fn is not supplied
if fn is None:
return lambda fn: register(hook_name, fn)
def decorator(fn):
register(hook_name, fn)
return fn
return decorator
if hook_name not in _hooks:
_hooks[hook_name] = []