diff options
Diffstat (limited to 'rest_framework/utils/formatting.py')
| -rw-r--r-- | rest_framework/utils/formatting.py | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/rest_framework/utils/formatting.py b/rest_framework/utils/formatting.py index a2a5609c..4bec8387 100644 --- a/rest_framework/utils/formatting.py +++ b/rest_framework/utils/formatting.py @@ -5,7 +5,7 @@ from __future__ import unicode_literals from django.utils.html import escape from django.utils.safestring import mark_safe -from rest_framework.compat import apply_markdown +from rest_framework.compat import apply_markdown, smart_text import re @@ -24,11 +24,6 @@ def _remove_leading_indent(content): Remove leading indent from a block of text. Used when generating descriptions from docstrings. """ - try: - content = content.decode('utf-8') - except (AttributeError, UnicodeEncodeError): - pass # the string should keep the default 'ascii' encoding in - # Python 2.x or stay a unicode string in Python 3.x whitespace_counts = [len(line) - len(line.lstrip(' ')) for line in content.splitlines()[1:] if line.lstrip()] @@ -68,7 +63,7 @@ def get_view_description(cls, html=False): Return a description for an `APIView` class or `@api_view` function. """ description = cls.__doc__ or '' - description = _remove_leading_indent(description) + description = _remove_leading_indent(smart_text(description)) if html: return markup_description(description) return description |
