Raise an exception if name is not provided when hooking a lambda function.

This commit is contained in:
Dave Marchant
2013-11-22 16:11:43 -08:00
parent 82f5a5660f
commit f5e3a4171d
+4 -1
View File
@@ -23,7 +23,10 @@ def hook(obj, method, name=None, overwrite=False, silent=False):
If name is None, the name of the method is used.
"""
if name is None: name = method.__name__
if name is None:
name = method.__name__
if name == '<lambda>':
raise Exception('Must provide name to hook lambda functions.')
if not hasattr(obj,name) or overwrite:
setattr(obj, name, types.MethodType( method, obj ))
if getattr(obj,'debug',False):