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

ascii codec can't encode character #5

Open
shaunmolloy opened this issue Apr 26, 2019 · 0 comments
Open

ascii codec can't encode character #5

shaunmolloy opened this issue Apr 26, 2019 · 0 comments

Comments

@shaunmolloy
Copy link

Error:

UnicodeEncodeError: 'ascii' codec can't encode character u'\u2018' in position 51: ordinal not in range(128)

Looks like the issue happens at this line
https://github.com/jorisroovers/yamlpal/blob/master/yamlpal/yaml_parser.py#L203

Applying utf8 encoding should solve it
https://stackoverflow.com/a/9942822

Stack trace:

Traceback (most recent call last):
  File "bin/yamlpal", line 11, in <module>
    sys.exit(cli())
  File "lib/python2.7/site-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "lib/python2.7/site-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "lib/python2.7/site-packages/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "lib/python2.7/site-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "lib/python2.7/site-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "lib/python2.7/site-packages/yamlpal/cli.py", line 101, in find
    found = find_in_file(needle, file, format)
  File "lib/python2.7/site-packages/yamlpal/cli.py", line 112, in find_in_file
    data = YamlParser.load_yaml(filecontents)
  File "lib/python2.7/site-packages/yamlpal/yaml_parser.py", line 93, in load_yaml
    return loader.get_single_data()
  File "lib/python2.7/site-packages/yaml/constructor.py", line 39, in get_single_data
    return self.construct_document(node)
  File "lib/python2.7/site-packages/yaml/constructor.py", line 48, in construct_document
    for dummy in generator:
  File "lib/python2.7/site-packages/yaml/constructor.py", line 398, in construct_yaml_map
    value = self.construct_mapping(node)
  File "lib/python2.7/site-packages/yaml/constructor.py", line 208, in construct_mapping
    return BaseConstructor.construct_mapping(self, node, deep=deep)
  File "lib/python2.7/site-packages/yaml/constructor.py", line 133, in construct_mapping
    value = self.construct_object(value_node, deep=deep)
  File "lib/python2.7/site-packages/yamlpal/yaml_parser.py", line 84, in construct_object
    data = LineStr(data)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2018' in position 51: ordinal not in range(128)
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