#37405: Using sort_keys kwarg no longer possible with YAML serializer
-------------------------------------+-------------------------------------
Reporter: Jacob | Owner: Jacob Walls
Walls |
Type: Bug | Status: assigned
Component: Core | Version: 6.1
(Serialization) |
Severity: Release | Keywords:
blocker |
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
The YAML serializer takes a `sort_keys` option, but since we neglected to
use `setdefault` when "defaulting" this argument in
7142667340f78403cbbcaa8f33703c494282b7b7, any existing uses could raise
`TypeError`:
Test case for `YamlSerializerTestCase`:
{{{#!py
def test_explicit_sort_keys(self):
serial_str = serializers.serialize(
"yaml", Author.objects.all(), sort_keys=False
)
self.assertTrue(self._validate_output(serial_str))
}}}
{{{#!py
File "/Users/jwalls/django/tests/serializers/test_yaml.py", line 159, in
test_explicit_sort_keys
serial_str = serializers.serialize("yaml", Author.objects.all(),
sort_keys=False)
^^^^^^^^^^^^^^^
File "/Users/jwalls/django/django/core/serializers/__init__.py", line
134, in serialize
s.serialize(queryset, **options)
^^^^^^^^^^^^^^^^^
File "/Users/jwalls/django/django/core/serializers/base.py", line 149,
in serialize
self.end_serialization()
^^^^^^^^^^^^^^^
File "/Users/jwalls/django/django/core/serializers/pyyaml.py", line 49,
in end_serialization
yaml.dump(
TypeError: yaml.dump() got multiple values for keyword argument
'sort_keys'
}}}
--
Ticket URL: <
https://code.djangoproject.com/ticket/37405>
Django <
https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.