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

Flatdict() doesn’t support deeply nested dictionaries #2

Closed
bfontaine opened this issue Dec 31, 2014 · 2 comments
Closed

Flatdict() doesn’t support deeply nested dictionaries #2

bfontaine opened this issue Dec 31, 2014 · 2 comments

Comments

@bfontaine
Copy link

Test:

import flatdict
d = {"foo": 42}
for _ in range(1000):
    d = {"1": d}  # create a 1000-levels nested dictionary
f = flatdict.FlatDict(d)

gives:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/private/tmp/toto/venv/lib/python2.7/site-packages/flatdict.py", line 27, in __init__
    self.__setitem__(key, value[key])
  File "/private/tmp/toto/venv/lib/python2.7/site-packages/flatdict.py", line 70, in __setitem__
    value = FlatDict(value, self._delimiter)
  File "/private/tmp/toto/venv/lib/python2.7/site-packages/flatdict.py", line 27, in __init__
    self.__setitem__(key, value[key])
  [… truncated …]
  File "/private/tmp/toto/venv/lib/python2.7/site-packages/flatdict.py", line 22, in __init__
    super(FlatDict, self).__init__()
RuntimeError: maximum recursion depth exceeded while calling a Python object

Tested with Flatdict 1.1.1 and Python 2.7.9.

If this can help you I recently released a similar library, flatkeys, and I worked around the maximum recursion depth limit by removing any recursion and using a stack instead.

@gmr
Copy link
Owner

gmr commented Jan 4, 2015

Thanks, that is an interesting use case I'd not thought of. I'll address this when I come up from air from a few other projects.

@gmr
Copy link
Owner

gmr commented Jun 10, 2019

Seems like it's an edge case for flatdict at this point, given no other reports or PRs to fix. Thanks for the report, but closing at this time.

@gmr gmr closed this as completed Jun 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants