Skip to content

config.cache is not maintaining sort order of dicts #9205

@BVMiko

Description

@BVMiko

I'm running into an issue where I'm losing the sort order of a dict object when storing it with the config.cache:

    request.config.cache.set('foo', {'b':1,'a':2})
    print(request.config.cache.get('foo', None))

Returns:

{'a': 2, 'b': 1}

This issue is caused by the sort_keys parameter here:

data = json.dumps(value, indent=2, sort_keys=True)

I'm assuming this was written with Python 2.x in mind, but now that Python 3.x dict is sorted this is causing an issue. Could this be removed so that sort order is maintained?

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueeasy issue that is friendly to new contributorplugin: cacherelated to the cache builtin plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions