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

New List results in RecursionError: maximum recursion depth exceeded in comparison #132

Open
hexcowboy opened this issue Sep 20, 2021 · 3 comments

Comments

@hexcowboy
Copy link

hexcowboy commented Sep 20, 2021

>>> from rlp.sedes import List

>>> attrs = [
...       {
...         "trait_type": "Hat", 
...         "value": "Bayc Flipped Brim"
...       }, 
...       {
...         "trait_type": "Eyes", 
...         "value": "X Eyes"
...       },
...     ]

>>> traits = list() 
>>> for attribute in attrs:
...     properties = [attribute.get("trait_type"), attribute.get("value")]
...     trait = List(properties)
...     traits.append(trait)
... 

Results in:

Traceback (most recent call last):
  File "<stdin>", line 3, in <module>
  File "/Users/cowboy/repos/loot.st/external-adapter/venv/lib/python3.9/site-packages/rlp/sedes/lists.py", line 57, in __init__
    self.append(List(e))
  File "/Users/cowboy/repos/loot.st/external-adapter/venv/lib/python3.9/site-packages/rlp/sedes/lists.py", line 57, in __init__
    self.append(List(e))
  File "/Users/cowboy/repos/loot.st/external-adapter/venv/lib/python3.9/site-packages/rlp/sedes/lists.py", line 57, in __init__
    self.append(List(e))
  [Previous line repeated 492 more times]
  File "/Users/cowboy/repos/loot.st/external-adapter/venv/lib/python3.9/site-packages/rlp/sedes/lists.py", line 56, in __init__
    elif isinstance(e, Sequence):
  File "/Users/cowboy/.brew/Cellar/[email protected]/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/abc.py", line 119, in __instancecheck__
    return _abc_instancecheck(cls, instance)
  File "/Users/cowboy/.brew/Cellar/[email protected]/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/abc.py", line 123, in __subclasscheck__
    return _abc_subclasscheck(cls, subclass)
RecursionError: maximum recursion depth exceeded in comparison
@pipermerriam
Copy link
Member

pipermerriam commented Sep 20, 2021

Take a look at how sedes objects like List are intended to be used: https://pyrlp.readthedocs.io/en/latest/tutorial.html#sedes-objects

They are "schema" meaning they are meant to be used alongside the "data". The code above should be something roughly:

>>> traits = list() 
>>> for attribute in attrs:
...     properties = [attribute.get("trait_type"), attribute.get("value")]
...     traits.append(properties)
... 
>>> rlp.encode(traits, List([List([binary, binary]]))

I didn't run the code above but it should be illustrative of the way the API should be used.

@pipermerriam
Copy link
Member

This is still a bug though as far as I'm concerned because the user should get a "sane" error in this case instead of this opaque recursion error.

@hexcowboy
Copy link
Author

They are "schema" meaning they are meant to be used alongside the "data".

This is a good explanation, thank you. The code sample is working.

This is still a bug though as far as I'm concerned because the user should get a "sane" error in this case instead of this opaque recursion error.

I'll leave it open for now.

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

No branches or pull requests

2 participants