X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=manifold%2Futil%2Ftype.py;h=1cc03b2b58a4ca234f1af3e8b049089520638695;hb=08bce207f8b92b8c93677c7b3bf749bd23fcdbc2;hp=5d7ab1eeaf35f9854cc1372c78c47e508a1df82a;hpb=1aea42c3668602aacfe22bc762ee939672129f53;p=unfold.git diff --git a/manifold/util/type.py b/manifold/util/type.py index 5d7ab1ee..1cc03b2b 100644 --- a/manifold/util/type.py +++ b/manifold/util/type.py @@ -60,9 +60,10 @@ def accepts(*types, **kw): debug = kw['debug'] try: def decorator(f): - def newf(*args): + # XXX Missing full support of kwargs + def newf(*args, **kwargs): if debug is 0: - return f(*args) + return f(*args, **kwargs) assert len(args) == len(types) argtypes = tuple(map(type, args)) if not compare_types(types, argtypes): @@ -72,7 +73,7 @@ def accepts(*types, **kw): print >> sys.stderr, 'TypeWarning: ', msg elif debug is 2: raise TypeError, msg - return f(*args) + return f(*args, **kwargs) newf.__name__ = f.__name__ return newf return decorator @@ -91,7 +92,7 @@ def compare_types(expected, actual): else: return actual == type(None) or actual in expected else: - return actual == type(None) or actual == expected or issubclass(actual, expected) + return actual == type(None) or actual == expected or isinstance(actual, expected) # issubclass(actual, expected) def returns(ret_type, **kw): '''Function decorator. Checks decorated function's return value