diff options
| author | Evan Heidtmann | 2015-02-26 09:00:51 -0800 | 
|---|---|---|
| committer | Evan Heidtmann | 2015-02-26 09:05:46 -0800 | 
| commit | bdb73d558891192c96368d5ca2266327302dba54 (patch) | |
| tree | 5a8909b8820a7a928c97c113a14cb3989523d993 /rest_framework | |
| parent | 16ffe5e31f80058389139fe5dae5184cc22319a6 (diff) | |
| download | django-rest-framework-bdb73d558891192c96368d5ca2266327302dba54.tar.bz2 | |
Avoid swallowing exceptions thrown in callable attributes
Diffstat (limited to 'rest_framework')
| -rw-r--r-- | rest_framework/fields.py | 6 | 
1 files changed, 5 insertions, 1 deletions
| diff --git a/rest_framework/fields.py b/rest_framework/fields.py index a5348922..01e7c78c 100644 --- a/rest_framework/fields.py +++ b/rest_framework/fields.py @@ -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 | 
