• 
      

    Support loading pickled data referencing SortedDict.

    Review Request #10557 — Created May 20, 2019 and submitted

    Information

    Django Evolution
    master

    Reviewers

    Django used to provide a class called SortedDict, which has long been
    deprecated in favor of Python's own OrderedDict. However, due to the
    way that pickling works, older signatures would still attempt to loading
    a SortedDict class.

    This change adds a compatibility mechanism for this. Upon finding an
    attempt to load a SortedDict, we instead give it a forwarding object
    that's compatible with the unpickle code that constructs a new
    OrderedDict. It's a bit hacky, in that we need to have this class that
    subclasses dict, overrides __new__, and then returns an entirely
    different object, but it's a necessity for the compatibility.

    Successfully loaded an older signature on Python 3.7/Django 1.11.

    Summary ID
    Support loading pickled data referencing SortedDict.
    Django used to provide a class called `SortedDict`, which has long been deprecated in favor of Python's own `OrderedDict`. However, due to the way that pickling works, older signatures would still attempt to loading a `SortedDict` class. This change adds a compatibility mechanism for this. Upon finding an attempt to load a `SortedDict`, we instead give it a forwarding object that's compatible with the unpickle code that constructs a new `OrderedDict`. It's a bit hacky, in that we need to have this class that subclasses `dict`, overrides `__new__`, and then returns an entirely different object, but it's a necessity for the compatibility.
    e44024fe0b0cb2005a401d3ab2b256fd9491dfef
    david
    1. Ship It!
    2. 
        
    chipx86
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to master (a610faf)