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

RecursionError in TDL parsing #294

Closed
goodmami opened this issue Jun 5, 2020 · 1 comment
Closed

RecursionError in TDL parsing #294

goodmami opened this issue Jun 5, 2020 · 1 comment
Labels
Milestone

Comments

@goodmami
Copy link
Member

goodmami commented Jun 5, 2020

The openproof/inflate-op.tdl file of the ERG has a list with over 1000 items in it, and this is causing a recursion error:

>>> from delphin import tdl
>>> list(tdl.iterparse('openproof/inflate-op.tdl'))
Traceback (most recent call last):
  [...]
  File "/home/goodmami/delphin/pydelphin/delphin/tdl.py", line 207, in __setitem__
    super(AVM, self).__setitem__(key, val)
  File "/home/goodmami/delphin/pydelphin/delphin/tfs.py", line 58, in __setitem__
    subdef[subkeys[1]] = val
  File "/home/goodmami/delphin/pydelphin/delphin/tdl.py", line 204, in __setitem__
    if not (val is None or isinstance(val, (Term, Conjunction))):
RecursionError: maximum recursion depth exceeded while calling a Python object

The list is flat, though, so it's probably not parsing that has a problem, but the list construction (REST.REST.REST.REST...).

@goodmami
Copy link
Member Author

goodmami commented Jul 1, 2020

The offending TDL definition in the ERG seems to have been removed, and anyway this is not something I expect to occur in normal TDL files. A simple solution is to just increase the recursion limit while parsing, so I'm not going to do a proper fix for this and instead catch the RecursionError and provide a more informative error for the user.

@goodmami goodmami added this to the v1.3.0 milestone Jul 1, 2020
goodmami added a commit that referenced this issue Jul 1, 2020
I expect the situation to be so rare that I'd rather just punt and let
the user handle it. The solution is simple, so I make PyDelphin give
an error message to explain what to do.

Of course, this doesn't *really* solve the problem if they have a TDL
list with an obscene number of items that goes beyond the stack limit,
but I'll wait for the problem to arise before I try to solve it.

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

No branches or pull requests

1 participant