Avoid swallowing exceptions thrown in callable attributes

This commit is contained in:
Evan Heidtmann 2015-02-26 09:00:51 -08:00
parent 16ffe5e31f
commit bdb73d5588

View File

@ -71,7 +71,11 @@ def get_attribute(instance, attrs):
except ObjectDoesNotExist:
return None
if is_simple_callable(instance):
try:
instance = instance()
except (AttributeError, KeyError) as exc:
raise ValueError('Exception raised in callable attribute "{0}"; original exception was: {1}'.format(attr, exc))
return instance