Skip to content

cache.py tuple() not hashable #8

Description

@tomkooij

I ran into some problems running checkpy because the following lines failed:

key = args + tuple(values) + tuple(sys.argv)
if key not in localCache:

It specifically failed when passing a list to a function that is wrapped by this cache.

A tuple is not guaranteed to be hashable, it fails when the tuple contains an unhashable type:

([]) in {}  # TypeError: unhashable type: 'list'

Solution: use str() to create hashable versions of any object (with __str___)

Perhaps I'll create a PR sometime :-)

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions