Skip to content

nested_hash fails on heterogeneous sets and dictionary keys #202

Description

@vitalivo

nested_hash sorts set members and dictionary items, which raises TypeError for ordinary heterogeneous containers. For example, on Python 3.12 and current master:

from dictdiffer.utils import nested_hash
nested_hash({1, "one"})
nested_hash({1: ["one"], "two": {3, "three"}})

Both calls raise TypeError: '<' not supported between instances of 'str' and 'int'. These values are otherwise valid nested data, and this helper is also used by Unifier.

A regression should verify that both calls succeed and that changing dictionary insertion order does not change the resulting hash. I have a fix using order-independent hashing with regression tests; run-tests.sh passes locally.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions