In order to determine if the context should be passed to a function or filter, Jinja has the contextfunction and contextfilter decorators which set corresponding attributes on the functions. However, they're checked with if getattr(f, "contextfunction", 0), which causes issues for objects that are callable and have permissive __getattr__ functions, such as Mock.
Changing everything to default to False and check is True, would be good for consistency.
The full list is contextfunction, evalcontextfunction, environmentfunction, contextfilter, evalcontextfilter, and environmentcontextfilter.
Extracted from #1139
In order to determine if the context should be passed to a function or filter, Jinja has the
contextfunctionandcontextfilterdecorators which set corresponding attributes on the functions. However, they're checked withif getattr(f, "contextfunction", 0), which causes issues for objects that are callable and have permissive__getattr__functions, such asMock.Changing everything to default to
Falseand checkis True, would be good for consistency.The full list is
contextfunction,evalcontextfunction,environmentfunction,contextfilter,evalcontextfilter, andenvironmentcontextfilter.Extracted from #1139