RecursionError: maximum recursion depth exceeded when calling `to_dict()` on `JsObjectWrapper` · Issue #242 · PiotrDabkowski/Js2Py · GitHub
Skip to content

RecursionError: maximum recursion depth exceeded when calling to_dict() on JsObjectWrapper #242

Description

@tristanlatr

Hi,

Thanks for this software, I'm hoping I can get the minified source code of https://github.com/olivernn/lunr.js translated to Python but I'm running into an error when trying to use the main lunr function.

Here is my code:

>>> js2py.translate_file('./pydoctor/templates/lunr.min.js', 'lunrlib.py')
>>> from lunrlib import lunrlib
>>> type(lunrlib)
<class 'js2py.base.JsObjectWrapper'>
>>> import sys
>>> sys.setrecursionlimit(12000)
>>> lunrlib.to_dict()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/tristan/.pyenv/versions/3.9.1/lib/python3.9/site-packages/js2py/base.py", line 1253, in __repr__
    return repr(self.to_dict())
  File "/Users/tristan/.pyenv/versions/3.9.1/lib/python3.9/site-packages/js2py/base.py", line 1253, in __repr__
    return repr(self.to_dict())
  File "/Users/tristan/.pyenv/versions/3.9.1/lib/python3.9/site-packages/js2py/base.py", line 1253, in __repr__
    return repr(self.to_dict())
  [Previous line repeated 243 more times]
  File "/Users/tristan/.pyenv/versions/3.9.1/lib/python3.9/site-packages/js2py/base.py", line 1247, in __repr__
    return repr(self._obj)
  File "/Users/tristan/.pyenv/versions/3.9.1/lib/python3.9/site-packages/js2py/base.py", line 976, in __repr__
    val = str_repr(self.to_string().value)
  File "/Users/tristan/.pyenv/versions/3.9.1/lib/python3.9/site-packages/js2py/base.py", line 611, in to_string
    return self.to_primitive('String').to_string()
  File "/Users/tristan/.pyenv/versions/3.9.1/lib/python3.9/site-packages/js2py/base.py", line 548, in to_primitive
    return self.default_value(hint)
  File "/Users/tristan/.pyenv/versions/3.9.1/lib/python3.9/site-packages/js2py/base.py", line 452, in default_value
    cand = method.call(self)
  File "/Users/tristan/.pyenv/versions/3.9.1/lib/python3.9/site-packages/js2py/base.py", line 1455, in call
    arguments = PyJsArguments(
  File "/Users/tristan/.pyenv/versions/3.9.1/lib/python3.9/site-packages/js2py/base.py", line 2777, in __init__
    self.define_own_property(
  File "/Users/tristan/.pyenv/versions/3.9.1/lib/python3.9/site-packages/js2py/base.py", line 462, in define_own_property
    current = self.get_own_property(prop)
  File "/Users/tristan/.pyenv/versions/3.9.1/lib/python3.9/site-packages/js2py/base.py", line 305, in get_own_property
    return self.own.get(prop)
RecursionError: maximum recursion depth exceeded while calling a Python object

The minified code can be found here: https://github.com/tristanlatr/pydoctor/blob/js-search/pydoctor/templates/lunr.min.js

The docs of lunr: https://lunrjs.com/docs/lunr.html

I suspect the issue comes from the fact that lunr name is namespace but also a function...

It would be really appreciated if we could find a workaround for this bug! Maybe if 2 names are conflicting, just rename it with an index appended and leave a warning ? or maybe there is way to make it work ?

Thanks!

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