diff options
| author | Paul Oswald | 2014-07-29 22:13:11 +0900 |
|---|---|---|
| committer | Paul Oswald | 2014-07-29 22:13:11 +0900 |
| commit | 66fa40c300b4d3e768b4a7993f020056c44fdda3 (patch) | |
| tree | 1cea10748a9a96dee84017992005c07d33b4d1d7 | |
| parent | 921e4ed2ee11edffd19d2ca40f10d47d2c148ea1 (diff) | |
| download | django-rest-framework-66fa40c300b4d3e768b4a7993f020056c44fdda3.tar.bz2 | |
evaluate content at function start
| -rw-r--r-- | rest_framework/utils/formatting.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/rest_framework/utils/formatting.py b/rest_framework/utils/formatting.py index 12b79b6c..2b3cbc95 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() |
