Commit fd003fce by José Padilla

Add pending deprecation warning message

parent 478c8d72
...@@ -3,6 +3,7 @@ Provides an APIView class that is the base of all views in REST framework. ...@@ -3,6 +3,7 @@ Provides an APIView class that is the base of all views in REST framework.
""" """
from __future__ import unicode_literals from __future__ import unicode_literals
import inspect import inspect
import warnings
from django.core.exceptions import PermissionDenied from django.core.exceptions import PermissionDenied
from django.http import Http404 from django.http import Http404
...@@ -370,13 +371,16 @@ class APIView(View): ...@@ -370,13 +371,16 @@ class APIView(View):
else: else:
exc.status_code = status.HTTP_403_FORBIDDEN exc.status_code = status.HTTP_403_FORBIDDEN
exception_handler = self.settings.EXCEPTION_HANDLER if len(inspect.getargspec(self.settings.EXCEPTION_HANDLER).args) == 1:
warnings.warn(
if 'context' in inspect.getargspec(exception_handler).args: 'The `exception_handler(exc)` call signature is deprecated. '
context = self.get_renderer_context() 'Use `exception_handler(exc, context) instead.',
response = exception_handler(exc, context) PendingDeprecationWarning
)
response = self.settings.EXCEPTION_HANDLER(exc)
else: else:
response = exception_handler(exc) context = self.get_renderer_context()
response = self.settings.EXCEPTION_HANDLER(exc, context)
if response is None: if response is None:
raise raise
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment