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

[BUG] Parsing a Python module with EOL escape but no continuation fails #186

Open
webknjaz opened this issue Aug 22, 2019 · 1 comment
Open

Comments

@webknjaz
Copy link
Contributor

Traceback (most recent call last):
  File "./migrate.py", line 657, in <module>
    main()
  File "./migrate.py", line 650, in main
    assemble_collections(spec, args)
  File "./migrate.py", line 422, in assemble_collections
    plugin_data_new, import_dependencies = rewrite_imports(plugin_data_new, collection, spec, args.namespace)
  File "./migrate.py", line 237, in rewrite_imports
    mod_fst = redbaron.RedBaron(mod_src_text)
  File "/home/bcoca/work/venvs/build_collection/lib/python3.7/site-packages/redbaron/redbaron.py", line 36, in __init__
    self.node_list = base_nodes.NodeList.from_fst(baron.parse(source_code), parent=self, on_attribute="root")
  File "/home/bcoca/work/venvs/build_collection/lib/python3.7/site-packages/baron/baron.py", line 66, in parse
    return _parse(tokens, print_function)
  File "/home/bcoca/work/venvs/build_collection/lib/python3.7/site-packages/baron/baron.py", line 24, in _parse
    return parser(tokens)
  File "/home/bcoca/work/venvs/build_collection/lib/python3.7/site-packages/baron/grammator.py", line 828, in parse
    return parser.parse(iter(tokens))
  File "/home/bcoca/work/venvs/build_collection/lib/python3.7/site-packages/baron/parser.py", line 167, in parse
    raise ParsingError(debug_output)
baron.parser.ParsingError: Error, got an unexpected token SPACE here:

 103
 104     def _execute_module_with_become(self, module_name, module_args, task_vars,
 105 wrap_async, use_task):
 106         orig_become = self._play_context.become
 107         orig_become_method = self._play_context.become_method
 108         orig_become_user = self._play_context.become_user\
 109
 110 <---- here

Place in the module where this happens: https://github.com/ansible/ansible/blob/8b882be/lib/ansible/plugins/action/win_updates.py#L108-L109

I've checked that

sss = 'some str'\
# some comment
print(sss)

and

sss = 'some str'\

print(sss)

works in CPython given that there's no tokens on the next line.

And

sss = 'some str'\
print(sss)

doesn't work (expected).

@webknjaz
Copy link
Contributor Author

Demo: PyCQA/baron#155

webknjaz added a commit to webknjaz/baron that referenced this issue Aug 22, 2019
webknjaz added a commit to webknjaz/baron that referenced this issue Aug 22, 2019
adharshsrivatsr pushed a commit to adharshsrivatsr/ansible that referenced this issue Sep 3, 2019
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