diff options
| author | Tom Christie | 2014-11-06 12:00:30 +0000 |
|---|---|---|
| committer | Tom Christie | 2014-11-06 12:00:30 +0000 |
| commit | 4e001dbb7ac0bc13d6d5fbb4524e905184610aa2 (patch) | |
| tree | f653aa5d1e0eaff780ba52039f29085e4bc8f54c /rest_framework/utils/encoders.py | |
| parent | 9923a6ce9013693ea1723e7895b3cab638d719fd (diff) | |
| download | django-rest-framework-4e001dbb7ac0bc13d6d5fbb4524e905184610aa2.tar.bz2 | |
Drop usage of SortedDict. Closes #2027.
Diffstat (limited to 'rest_framework/utils/encoders.py')
| -rw-r--r-- | rest_framework/utils/encoders.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/rest_framework/utils/encoders.py b/rest_framework/utils/encoders.py index 486186c9..4d6bb3a3 100644 --- a/rest_framework/utils/encoders.py +++ b/rest_framework/utils/encoders.py @@ -4,9 +4,8 @@ Helper classes for parsers. from __future__ import unicode_literals from django.db.models.query import QuerySet from django.utils import six, timezone -from django.utils.datastructures import SortedDict from django.utils.functional import Promise -from rest_framework.compat import force_text +from rest_framework.compat import force_text, OrderedDict import datetime import decimal import types @@ -68,7 +67,7 @@ else: class SafeDumper(yaml.SafeDumper): """ Handles decimals as strings. - Handles SortedDicts as usual dicts, but preserves field order, rather + Handles OrderedDicts as usual dicts, but preserves field order, rather than the usual behaviour of sorting the keys. """ def represent_decimal(self, data): @@ -82,7 +81,7 @@ else: best_style = True if hasattr(mapping, 'items'): mapping = list(mapping.items()) - if not isinstance(mapping, SortedDict): + if not isinstance(mapping, OrderedDict): mapping.sort() for item_key, item_value in mapping: node_key = self.represent_data(item_key) @@ -104,7 +103,7 @@ else: SafeDumper.represent_decimal ) SafeDumper.add_representer( - SortedDict, + OrderedDict, yaml.representer.SafeRepresenter.represent_dict ) # SafeDumper.add_representer( @@ -112,7 +111,7 @@ else: # yaml.representer.SafeRepresenter.represent_dict # ) # SafeDumper.add_representer( - # SortedDictWithMetadata, + # OrderedDictWithMetadata, # yaml.representer.SafeRepresenter.represent_dict # ) SafeDumper.add_representer( |
