From 77318b23dff36e6848423998d6288917d256fd7e Mon Sep 17 00:00:00 2001 From: Zachary Pavlov Date: Fri, 19 Mar 2010 22:49:24 +0000 Subject: [PATCH] hasattr(function, __call__) is not a valid callable check! use callable instead, which catches inittable objects --- direct/src/showbase/PythonUtil.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/direct/src/showbase/PythonUtil.py b/direct/src/showbase/PythonUtil.py index 1a8814ffd0..1ba4e5e009 100644 --- a/direct/src/showbase/PythonUtil.py +++ b/direct/src/showbase/PythonUtil.py @@ -92,7 +92,7 @@ def Functor(function, *args, **kArgs): class Functor: def __init__(self, function, *args, **kargs): - assert hasattr(function, '__call__'), "function should be a callable obj" + assert callable(function), "function should be a callable obj" self._function = function self._args = args self._kargs = kargs @@ -117,7 +117,7 @@ class Functor: _kargs.update(kargs) return self._function(*(self._args + args), **_kargs) - # this method is used in place of __call__ if we are recording creation stacks + # this methoxd is used in place of __call__ if we are recording creation stacks def _exceptionLoggedCreationStack__call__(self, *args, **kargs): try: return self._do__call__(*args, **kargs)