diff --git a/rest_framework/utils/formatting.py b/rest_framework/utils/formatting.py index 12b79b6cd..2b3cbc957 100644 --- a/rest_framework/utils/formatting.py +++ b/rest_framework/utils/formatting.py @@ -28,13 +28,14 @@ def dedent(content): as it fails to dedent multiline docstrings that include unindented text on the initial line. """ + content = unicode(content) whitespace_counts = [len(line) - len(line.lstrip(' ')) for line in content.splitlines()[1:] if line.lstrip()] # unindent the content if needed if whitespace_counts: whitespace_pattern = '^' + (' ' * min(whitespace_counts)) - content = re.sub(re.compile(whitespace_pattern, re.MULTILINE), '', unicode(content)) + content = re.sub(re.compile(whitespace_pattern, re.MULTILINE), '', content) return content.strip()