diff options
| author | Tom Christie | 2014-10-30 16:53:12 +0000 |
|---|---|---|
| committer | Tom Christie | 2014-10-30 16:53:12 +0000 |
| commit | cd40dcb06500424ef9016913a1a89db0deed8a1f (patch) | |
| tree | 2023aa697c7916f264677dcce07d6142f5a6f496 /rest_framework/compat.py | |
| parent | 0dea509dc9847206d830a0e48b91fa1c5b8ac52e (diff) | |
| download | django-rest-framework-cd40dcb06500424ef9016913a1a89db0deed8a1f.tar.bz2 | |
Ensure json.dumps(separators=...) works on both 2.x and 3.x
Diffstat (limited to 'rest_framework/compat.py')
| -rw-r--r-- | rest_framework/compat.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/rest_framework/compat.py b/rest_framework/compat.py index 4ab23a4d..0201bd83 100644 --- a/rest_framework/compat.py +++ b/rest_framework/compat.py @@ -291,6 +291,15 @@ except ImportError: oauth2_constants = None provider_now = None +# `seperators` argument to `json.dumps()` differs between 2.x and 3.x +# See: http://bugs.python.org/issue22767 +if six.PY3: + SHORT_SEPARATORS = (',', ':') + LONG_SEPARATORS = (', ', ': ') +else: + SHORT_SEPARATORS = (b',', b':') + LONG_SEPARATORS = (b', ', b': ') + # Handle lazy strings across Py2/Py3 from django.utils.functional import Promise |
