Describe the bug
When I import an something of type DotMap from another module in my code, and try to document my module with auto doc; I get the following failure during make html:
Recursion error:
maximum recursion depth exceeded while getting the str of an object
This can happen with very large or deeply nested source files. You can carefully increase the default Python recursion limit of 1000 in
conf.py with e.g.:
import sys; sys.setrecursionlimit(1500)
I think this is potentially a regression as I was not able to reproduce the issue with Sphinx 2.4.0?
To Reproduce
Steps to reproduce the behavior:
# unzip reference project (attached) and ...
python3 -m venv ~/venvs/sphinx_vs_dotmap
. ~/venvs/sphinx_vs_dotmap/bin/activate
pip install sphinx dotmap
export PYTHONPATH=$PWD
make html
Expected behavior
make html to succeed.
Your project
sphinx_vs_dotmap.zip has been attached:
sphinx_vs_dotmap.zip
Screenshots
N/A
Environment info
Additional context
Add any other context about the problem here.
Also confirmed with MacBook Catalina running Python 3.7.
And confirmed that when I replace install from the the reproduction steps with 2.4.0, I do not observe the issue:
pip install sphinx==2.4.0 dotmap
I confirmed inspect.unwrap(dotmap) causes a RecursionError. I don't know what is happened inside dotmap library. But it seems repr(dotmap) causes recursive calls. Is this intended behavior?
root@fa4e9e8d3a2d:/docs/sphinx_vs_dotmap# python3
Python 3.6.9 (default, Nov 7 2019, 10:44:02)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import inspect
>>> import sys
>>> import dotmap_exporter
>>> sys.setrecursionlimit(50)
>>> inspect.unwrap(dotmap_exporter.testdotmap)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.6/inspect.py", line 516, in unwrap
raise ValueError('wrapper loop when unwrapping {!r}'.format(f))
File "/usr/local/lib/python3.6/dist-packages/dotmap/__init__.py", line 125, in __repr__
return str(self)
File "/usr/local/lib/python3.6/dist-packages/dotmap/__init__.py", line 119, in __str__
items.append('{0}={1}'.format(k, repr(v)))
File "/usr/local/lib/python3.6/dist-packages/dotmap/__init__.py", line 125, in __repr__
return str(self)
File "/usr/local/lib/python3.6/dist-packages/dotmap/__init__.py", line 119, in __str__
items.append('{0}={1}'.format(k, repr(v)))
File "/usr/local/lib/python3.6/dist-packages/dotmap/__init__.py", line 125, in __repr__
return str(self)
File "/usr/local/lib/python3.6/dist-packages/dotmap/__init__.py", line 119, in __str__
items.append('{0}={1}'.format(k, repr(v)))
File "/usr/local/lib/python3.6/dist-packages/dotmap/__init__.py", line 125, in __repr__
return str(self)
File "/usr/local/lib/python3.6/dist-packages/dotmap/__init__.py", line 119, in __str__
items.append('{0}={1}'.format(k, repr(v)))
File "/usr/local/lib/python3.6/dist-packages/dotmap/__init__.py", line 125, in __repr__
return str(self)
File "/usr/local/lib/python3.6/dist-packages/dotmap/__init__.py", line 119, in __str__
items.append('{0}={1}'.format(k, repr(v)))
RecursionError: maximum recursion depth exceeded
@tk0miya thank you very much again for your help with this issue. Having followed up on your technical input I have raised in DotMap source repo and offered a potential pull-request to resolve. As such, am closing this ticket
Most helpful comment
I confirmed
inspect.unwrap(dotmap)causes aRecursionError. I don't know what is happened inside dotmap library. But it seemsrepr(dotmap)causes recursive calls. Is this intended behavior?