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

PyParsing issue (and work-around) #74

Closed
vanrein opened this issue Dec 1, 2021 · 4 comments
Closed

PyParsing issue (and work-around) #74

vanrein opened this issue Dec 1, 2021 · 4 comments

Comments

@vanrein
Copy link

vanrein commented Dec 1, 2021

Problem: Using asn1ate 0.6.0 as packaged for Python 3.9, we discovered a problem with PyParsing 3.0.6; this caused exceptions when using OPTIONAL or DEFAULT x annotations,

  File ".../asn1ate-0.6.0-py3.7.egg/asn1ate/sema.py", line 474, in <listcomp>
    for token in component_tokens]
  File ".../asn1ate-0.6.0-py3.7.egg/asn1ate/sema.py", line 994, in _create_sema_node
    raise Exception('Unknown token type: %s' % token.ty)
Exception: Unknown token type: ComponentTypeOptional

Workaround: We worked around it by demanding an older version, namely 3.0.0, of PyParsing.

Question: It is not quite clear if this is only due to PyParsing; there may be something wrong with asn1ate that gets triggered. This most likely is in sema.py function _create_sema_node() which has

    elif token.ty == 'ComponentType':
        return ComponentType(token.elements)

but no cases for ComponentTypeOptional, ComponentTypeDefault, ComponentTypeComponentsOf. When I added such cases under PyParsing 3.0.6, it ran into a problem using the elements array, which I could not furhter assign to my thinking or that in the sema.py module.

@kimgr
Copy link
Owner

kimgr commented Dec 2, 2021

Thank you! Funny enough, I experimented with asn1ate just last week and ran into the same problem. And settled on the same workaround 🙂. But it sounds like there's a deeper problem that should be addressed, so I'll try to get to the bottom of it and see if there's a solution that works with both old and new pyparsing.

@kimgr
Copy link
Owner

kimgr commented Dec 13, 2021

I filed this: pyparsing/pyparsing#345. Reverting the commit pyparsing/pyparsing@9987004 makes asn1ate's test suite work again, so I'm inclined to think it's an isolated pyparsing behavior that triggers it.

@vanrein
Copy link
Author

vanrein commented Dec 15, 2021 via email

@kimgr
Copy link
Owner

kimgr commented Dec 15, 2021

Thanks, I just pushed a stricter setup.py excluding the known-broken versions from install dependencies. It turns out 3.0.4 also works, so you can install that as a workaround.

Closing.

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