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

help(parse_tree) trigger an AssertionError #82

Closed
mdamien opened this issue Oct 10, 2020 · 1 comment
Closed

help(parse_tree) trigger an AssertionError #82

mdamien opened this issue Oct 10, 2020 · 1 comment

Comments

@mdamien
Copy link
Contributor

mdamien commented Oct 10, 2020

I'm using the calc example:

  File "calc.py", line 125, in main
    help(parse_tree)
  File "/home/damien/.venv/lib/python3.6/site.py", line 505, in __call__
    return pydoc.help(*args, **kwds)
  File "/usr/lib/python3.6/pydoc.py", line 1864, in __call__
    self.help(request)
  File "/usr/lib/python3.6/pydoc.py", line 1923, in help
    else: doc(request, 'Help on %s:', output=self._output)
  File "/usr/lib/python3.6/pydoc.py", line 1650, in doc
    pager(render_doc(thing, title, forceload))
  File "/usr/lib/python3.6/pydoc.py", line 1625, in render_doc
    object, name = resolve(thing, forceload)
  File "/usr/lib/python3.6/pydoc.py", line 1617, in resolve
    name = getattr(thing, '__name__', None)
  File "../arpeggio/__init__.py", line 1170, in __getattr__
    result = NonTerminal(rule=rule, nodes=nodes, _filtered=True)
  File ".../arpeggio/__init__.py", line 1098, in __init__
    super(NonTerminal, self).__init__(rule, position, error)
  File ".../arpeggio/__init__.py", line 971, in __init__
    assert rule

It's also simply triggered by parse_tree.__name__

Looks like it's because parse_tree. is used to find a child and __name__ is not a child

Adding a simple __name__ method to NonTerminal fix the issue:

class NonTerminal(ParseTreeNode, list):
...
    def __name__(self):
        return 'test'
@igordejanovic
Copy link
Member

Thanks for reporting. Actually, accessing any non-existing attribute on a parse tree node was leading to assertion error. With this fix it will be correctly handled by raising AttributeError.

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