mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-25 19:14:01 +03:00
Avoid swallowing exceptions thrown in callable attributes
This commit is contained in:
parent
16ffe5e31f
commit
bdb73d5588
|
@ -71,7 +71,11 @@ def get_attribute(instance, attrs):
|
|||
except ObjectDoesNotExist:
|
||||
return None
|
||||
if is_simple_callable(instance):
|
||||
instance = 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
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user