diff --git a/jinja2/runtime.py b/jinja2/runtime.py index 5916d90bd..f9d7a6806 100644 --- a/jinja2/runtime.py +++ b/jinja2/runtime.py @@ -242,13 +242,14 @@ def call(__self, __obj, *args, **kwargs): __traceback_hide__ = True # noqa # Allow callable classes to take a context - fn = __obj.__call__ - for fn_type in ('contextfunction', - 'evalcontextfunction', - 'environmentfunction'): - if hasattr(fn, fn_type): - __obj = fn - break + if hasattr(__obj, '__call__'): + fn = __obj.__call__ + for fn_type in ('contextfunction', + 'evalcontextfunction', + 'environmentfunction'): + if hasattr(fn, fn_type): + __obj = fn + break if isinstance(__obj, _context_function_types): if getattr(__obj, 'contextfunction', 0):