Unhandled exception traceback hides exception original string on python 2.7 · Issue #4631 · encode/django-rest-framework (original) (raw)
After commit e3686ac (3.5.1 version) python 2.7 traceback for unhandled exceptions no longer contain line where exception occured, because we're reraising exception explicitly.
File "/Users/coagulant/.envs/myproject/lib/python2.7/site-packages/rest_framework/viewsets.py", line 83, in view
return self.dispatch(request, *args, **kwargs)
File "/Users/coagulant/.envs/myproject/lib/python2.7/site-packages/rest_framework/views.py", line 477, in dispatch
response = self.handle_exception(exc)
File "/Users/coagulant/.envs/myproject/lib/python2.7/site-packages/rest_framework/views.py", line 437, in handle_exception
self.raise_uncaught_exception(exc)
File "/Users/coagulant/.envs/myproject/lib/python2.7/site-packages/rest_framework/views.py", line 448, in raise_uncaught_exception
raise exc
KeyError: 'request'
Full tracebacks:
Traceback on DRF 3.5.0 (good behavior)
Traceback (most recent call last):
File "/Users/coagulant/projects/myproject/project/tests/api/account_tests.py", line 346, in test_put_account_detail_restricted_fields_200
{'email': u'some.unconfirmed@email.com'})
File "/Users/coagulant/.envs/myproject/lib/python2.7/site-packages/rest_framework/test.py", line 307, in put
path, data=data, format=format, content_type=content_type, **extra)
File "/Users/coagulant/.envs/myproject/lib/python2.7/site-packages/rest_framework/test.py", line 225, in put
return self.generic('PUT', path, data, content_type, **extra)
File "/Users/coagulant/.envs/myproject/lib/python2.7/site-packages/django/test/client.py", line 380, in generic
return self.request(**r)
File "/Users/coagulant/projects/myproject/project/tests/fixtures/clients.py", line 27, in request
return super(DRFAPIClient, self).request(**kwargs)
File "/Users/coagulant/projects/myproject/project/tests/fixtures/clients.py", line 17, in request
return super(AutoPrependBasePathMixin, self).request(**kwargs)
File "/Users/coagulant/.envs/myproject/lib/python2.7/site-packages/rest_framework/test.py", line 288, in request
return super(APIClient, self).request(**kwargs)
File "/Users/coagulant/.envs/myproject/lib/python2.7/site-packages/rest_framework/test.py", line 240, in request
request = super(APIRequestFactory, self).request(**kwargs)
File "/Users/coagulant/.envs/myproject/lib/python2.7/site-packages/django/test/client.py", line 449, in request
response = self.handler(environ)
File "/Users/coagulant/.envs/myproject/lib/python2.7/site-packages/django/test/client.py", line 123, in __call__
response = self.get_response(request)
File "/Users/coagulant/.envs/myproject/lib/python2.7/site-packages/rest_framework/test.py", line 260, in get_response
return super(ForceAuthClientHandler, self).get_response(request)
File "/Users/coagulant/.envs/myproject/lib/python2.7/site-packages/django/core/handlers/base.py", line 230, in get_response
response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
File "/Users/coagulant/.envs/myproject/lib/python2.7/site-packages/django/core/handlers/base.py", line 149, in get_response
response = self.process_exception_by_middleware(e, request)
File "/Users/coagulant/.envs/myproject/lib/python2.7/site-packages/django/core/handlers/base.py", line 147, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/coagulant/.envs/myproject/lib/python2.7/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
return view_func(*args, **kwargs)
File "/Users/coagulant/.envs/myproject/lib/python2.7/site-packages/rest_framework/viewsets.py", line 83, in view
return self.dispatch(request, *args, **kwargs)
File "/Users/coagulant/.envs/myproject/lib/python2.7/site-packages/rest_framework/views.py", line 477, in dispatch
response = self.handle_exception(exc)
File "/Users/coagulant/.envs/myproject/lib/python2.7/site-packages/rest_framework/views.py", line 437, in handle_exception
self.raise_uncaught_exception(exc)
File "/Users/coagulant/.envs/myproject/lib/python2.7/site-packages/rest_framework/views.py", line 474, in dispatch
response = handler(request, *args, **kwargs)
File "/Users/coagulant/.envs/myproject/lib/python2.7/site-packages/rest_framework/mixins.py", line 78, in update
return Response(serializer.data)
File "/Users/coagulant/.envs/myproject/lib/python2.7/site-packages/rest_framework/serializers.py", line 504, in data
ret = super(Serializer, self).data
File "/Users/coagulant/.envs/myproject/lib/python2.7/site-packages/rest_framework/serializers.py", line 239, in data
self._data = self.to_representation(self.instance)
File "/Users/coagulant/.envs/myproject/lib/python2.7/site-packages/rest_framework/serializers.py", line 473, in to_representation
ret[field.field_name] = field.to_representation(attribute)
File "/Users/coagulant/.envs/myproject/lib/python2.7/site-packages/rest_framework/relations.py", line 371, in to_representation
url = self.get_url(value, self.view_name, request, format)
File "/Users/coagulant/projects/myproject/project/api/serializers.py", line 19, in get_url
version = kwargs['request'].version
KeyError: 'request'
Traceback on DRF 3.5.1 (unexpected behavior)
Traceback (most recent call last):
File "/Users/coagulant/projects/myproject/project/tests/api/account_tests.py", line 346, in test_put_account_detail_restricted_fields_200
{'email': u'some.unconfirmed@email.com'})
File "/Users/coagulant/.envs/myproject/lib/python2.7/site-packages/rest_framework/test.py", line 307, in put
path, data=data, format=format, content_type=content_type, **extra)
File "/Users/coagulant/.envs/myproject/lib/python2.7/site-packages/rest_framework/test.py", line 225, in put
return self.generic('PUT', path, data, content_type, **extra)
File "/Users/coagulant/.envs/myproject/lib/python2.7/site-packages/django/test/client.py", line 380, in generic
return self.request(**r)
File "/Users/coagulant/projects/myproject/project/tests/fixtures/clients.py", line 27, in request
return super(DRFAPIClient, self).request(**kwargs)
File "/Users/coagulant/projects/myproject/project/tests/fixtures/clients.py", line 17, in request
return super(AutoPrependBasePathMixin, self).request(**kwargs)
File "/Users/coagulant/.envs/myproject/lib/python2.7/site-packages/rest_framework/test.py", line 288, in request
return super(APIClient, self).request(**kwargs)
File "/Users/coagulant/.envs/myproject/lib/python2.7/site-packages/rest_framework/test.py", line 240, in request
request = super(APIRequestFactory, self).request(**kwargs)
File "/Users/coagulant/.envs/myproject/lib/python2.7/site-packages/django/test/client.py", line 449, in request
response = self.handler(environ)
File "/Users/coagulant/.envs/myproject/lib/python2.7/site-packages/django/test/client.py", line 123, in __call__
response = self.get_response(request)
File "/Users/coagulant/.envs/myproject/lib/python2.7/site-packages/rest_framework/test.py", line 260, in get_response
return super(ForceAuthClientHandler, self).get_response(request)
File "/Users/coagulant/.envs/myproject/lib/python2.7/site-packages/django/core/handlers/base.py", line 230, in get_response
response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
File "/Users/coagulant/.envs/myproject/lib/python2.7/site-packages/django/core/handlers/base.py", line 149, in get_response
response = self.process_exception_by_middleware(e, request)
File "/Users/coagulant/.envs/myproject/lib/python2.7/site-packages/django/core/handlers/base.py", line 147, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/coagulant/.envs/myproject/lib/python2.7/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
return view_func(*args, **kwargs)
File "/Users/coagulant/.envs/myproject/lib/python2.7/site-packages/rest_framework/viewsets.py", line 83, in view
return self.dispatch(request, *args, **kwargs)
File "/Users/coagulant/.envs/myproject/lib/python2.7/site-packages/rest_framework/views.py", line 477, in dispatch
response = self.handle_exception(exc)
File "/Users/coagulant/.envs/myproject/lib/python2.7/site-packages/rest_framework/views.py", line 437, in handle_exception
self.raise_uncaught_exception(exc)
File "/Users/coagulant/.envs/myproject/lib/python2.7/site-packages/rest_framework/views.py", line 448, in raise_uncaught_exception
raise exc
KeyError: 'request'