Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot handle unhashable types in function arguments #36

Open
thet opened this issue Jul 6, 2023 · 0 comments · May be fixed by #37
Open

Cannot handle unhashable types in function arguments #36

thet opened this issue Jul 6, 2023 · 0 comments · May be fixed by #37

Comments

@thet
Copy link
Member

thet commented Jul 6, 2023

plone.memoize.view.memoize cannot handle function arguments which are unhashable types.

E.g.:

When adding this example to view.rst:

$ git diff
diff --git a/plone/memoize/view.rst b/plone/memoize/view.rst
index 45de49c..bb92b48 100644
--- a/plone/memoize/view.rst
+++ b/plone/memoize/view.rst
@@ -89,6 +89,9 @@ We support memoization of multiple signatures as long as all signature values ar
     >>> print(msg.getMsg('J.D.', **{'raise':'roofbeams'}))
     J.D.: goodbye cruel world! raise--roofbeams
 
+    >>> print(msg.getMsg('J.D.', lower=['shields', 'engines']))
+    J.D.: goodbye cruel world! lower--['shields', 'engines']
+
 We can alter data underneath, but nothing changes::
 
     >>> msg.txt1 = 'sound and fury'

Running the tests with tox run -e py311 fails with::

File "plone.memoize/.tox/py311/lib/python3.11/site-packages/plone/memoize/view.rst", line 92, in view.rst
Failed example:
    print(msg.getMsg('J.D.', lower=['shields', 'engines']))
Exception raised:
    Traceback (most recent call last):
      File "~/.pyenv/versions/3.11.2/lib/python3.11/doctest.py", line 1351, in __run
        exec(compile(example.source, filename, "single",
      File "<doctest view.rst[23]>", line 1, in <module>
        print(msg.getMsg('J.D.', lower=['shields', 'engines']))
      File "plone.memoize/.tox/py311/lib/python3.11/site-packages/plone/memoize/view.py", line 47, in memogetter
        frozenset(kwargs.items()),
    TypeError: unhashable type: 'list'

Likewise with dicts:

Adding:

$ git diff
diff --git a/plone/memoize/view.rst b/plone/memoize/view.rst
index 45de49c..8589dd3 100644
--- a/plone/memoize/view.rst
+++ b/plone/memoize/view.rst
@@ -89,6 +89,9 @@ We support memoization of multiple signatures as long as all signature values ar
     >>> print(msg.getMsg('J.D.', **{'raise':'roofbeams'}))
     J.D.: goodbye cruel world! raise--roofbeams
 
+    >>> print(msg.getMsg('J.D.', actions={'open': ['gates']}))
+    J.D.: goodbye cruel world! actions--{'open': ['gates']}
+
 We can alter data underneath, but nothing changes::
 
     >>> msg.txt1 = 'sound and fury'

tox run -e py311 Results in:

File "plone.memoize/.tox/py311/lib/python3.11/site-packages/plone/memoize/view.rst", line 92, in view.rst
Failed example:
    print(msg.getMsg('J.D.', actions={'open': ['gates']}))
Exception raised:
    Traceback (most recent call last):
      File "~/.pyenv/versions/3.11.2/lib/python3.11/doctest.py", line 1351, in __run
        exec(compile(example.source, filename, "single",
      File "<doctest view.rst[23]>", line 1, in <module>
        print(msg.getMsg('J.D.', actions={'open': ['gates']}))
      File "plone.memoize/.tox/py311/lib/python3.11/site-packages/plone/memoize/view.py", line 47, in memogetter
        frozenset(kwargs.items()),
    TypeError: unhashable type: 'dict'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant