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

Crash when dict unpacking for dict merging #153

Closed
PaulRenvoise opened this issue Jun 13, 2019 · 1 comment
Closed

Crash when dict unpacking for dict merging #153

PaulRenvoise opened this issue Jun 13, 2019 · 1 comment

Comments

@PaulRenvoise
Copy link

PaulRenvoise commented Jun 13, 2019

A not-so-usual way of merging dict is the following:

first_dict = {'a': 1, 'b': 2, 'c': 3}
second_dict = {'a': 10, 'b': 20}

merged_dict = {**first_dict, **second_dict}

Currently this approach makes baron crash with the following backtrace:

Traceback (most recent call last):
  File ".../.pyenv/versions/3.7.1/Python.framework/Versions/3.7/lib/python3.7/site-packages/baron/baron.py", line 20, in _parse
    return parser(tokens)
  File ".../.pyenv/versions/3.7.1/Python.framework/Versions/3.7/lib/python3.7/site-packages/baron/grammator.py", line 828, in parse
    return parser.parse(iter(tokens))
  File ".../.pyenv/versions/3.7.1/Python.framework/Versions/3.7/lib/python3.7/site-packages/baron/parser.py", line 167, in parse
    raise ParsingError(debug_output)
baron.parser.ParsingError: Error, got an unexpected token DOUBLE_STAR here:

   1 merged_dict = {**<---- here

The token DOUBLE_STAR should be one of those: BACKQUOTE, BINARY, BINARY_RAW_STRING, BINARY_STRING, COMPLEX, ELLIPSIS, FLOAT, FLOAT_EXPONANT, FLOAT_EXPONANT_COMPLEX, HEXA, INT, INTERPOLATED_RAW_STRING, INTERPOLATED_STRING, LAMBDA, LEFT_BRACKET, LEFT_PARENTHESIS, LEFT_SQUARE_BRACKET, LONG, MINUS, NAME, NOT, OCTA, PLUS, RAW_STRING, RIGHT_BRACKET, STRING, TILDE, UNICODE_RAW_STRING, UNICODE_STRING

Baron has failed to parse this input. If this is valid python code (and by that I mean that the python binary successfully parse this code without any syntax error) (also consider that python does not yet parse python 3 code integrally) it would be kind if you can extract a snippet of your code that make Baron fails and open a bug here: https://github.com/PyCQA/baron/issues

Sorry for the inconvenience.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../.pyenv/versions/3.7.1/Python.framework/Versions/3.7/lib/python3.7/site-packages/baron/baron.py", line 57, in parse
    to_return = _parse(tokens, print_function)
  File ".../.pyenv/versions/3.7.1/Python.framework/Versions/3.7/lib/python3.7/site-packages/baron/baron.py", line 24, in _parse
    return parser(tokens)
  File ".../.pyenv/versions/3.7.1/Python.framework/Versions/3.7/lib/python3.7/site-packages/baron/grammator.py", line 828, in parse
    return parser.parse(iter(tokens))
  File ".../.pyenv/versions/3.7.1/Python.framework/Versions/3.7/lib/python3.7/site-packages/baron/parser.py", line 167, in parse
    raise ParsingError(debug_output)
baron.parser.ParsingError: Error, got an unexpected token DOUBLE_STAR here:

   1 merged_dict = {**<---- here

The token DOUBLE_STAR should be one of those: BACKQUOTE, BINARY, BINARY_RAW_STRING, BINARY_STRING, COMPLEX, ELLIPSIS, FLOAT, FLOAT_EXPONANT, FLOAT_EXPONANT_COMPLEX, HEXA, INT, INTERPOLATED_RAW_STRING, INTERPOLATED_STRING, LAMBDA, LEFT_BRACKET, LEFT_PARENTHESIS, LEFT_SQUARE_BRACKET, LONG, MINUS, NAME, NOT, OCTA, PLUS, RAW_STRING, RIGHT_BRACKET, STRING, TILDE, UNICODE_RAW_STRING, UNICODE_STRING

Baron has failed to parse this input. If this is valid python code (and by that I mean that the python binary successfully parse this code without any syntax error) (also consider that python does not yet parse python 3 code integrally) it would be kind if you can extract a snippet of your code that make Baron fails and open a bug here: https://github.com/PyCQA/baron/issues

Sorry for the inconvenience.
@PaulRenvoise
Copy link
Author

Duplicate of #137

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

1 participant