Skip to content

Commit

Permalink
Merge pull request #502 from berrange/callable
Browse files Browse the repository at this point in the history
runtime: avoid assumption that all objects provide __call__
  • Loading branch information
davidism committed Jul 7, 2017
2 parents e276843 + 91255f8 commit 07c0b87
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions jinja2/runtime.py
Expand Up @@ -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):
Expand Down

0 comments on commit 07c0b87

Please sign in to comment.