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

Crashes on encountering emojis #48

Closed
adamchainz opened this issue Apr 4, 2017 · 8 comments
Closed

Crashes on encountering emojis #48

adamchainz opened this issue Apr 4, 2017 · 8 comments

Comments

@adamchainz
Copy link
Contributor

Apparently PyYAML just crashes when loading emoji, but it's not clear why:

$ echo 💩 > test.yml
$ yamllint test.yml
Traceback (most recent call last):
  File "/usr/local/bin/yamllint", line 11, in <module>
    sys.exit(run())
  File "/usr/local/lib/python2.7/site-packages/yamllint/cli.py", line 119, in run
    for problem in linter.run(f, conf):
  File "/usr/local/lib/python2.7/site-packages/yamllint/linter.py", line 184, in _run
    syntax_error = get_syntax_error(buffer)
  File "/usr/local/lib/python2.7/site-packages/yamllint/linter.py", line 169, in get_syntax_error
    list(yaml.parse(buffer, Loader=yaml.BaseLoader))
  File "/usr/local/lib/python2.7/site-packages/yaml/__init__.py", line 34, in parse
    loader = Loader(stream)
  File "/usr/local/lib/python2.7/site-packages/yaml/loader.py", line 14, in __init__
    Reader.__init__(self, stream)
  File "/usr/local/lib/python2.7/site-packages/yaml/reader.py", line 79, in __init__
    self.determine_encoding()
  File "/usr/local/lib/python2.7/site-packages/yaml/reader.py", line 135, in determine_encoding
    self.update(1)
  File "/usr/local/lib/python2.7/site-packages/yaml/reader.py", line 169, in update
    self.check_printable(data)
  File "/usr/local/lib/python2.7/site-packages/yaml/reader.py", line 144, in check_printable
    'unicode', "special characters are not allowed")
yaml.reader.ReaderError: unacceptable character #xd83d: special characters are not allowed
  in "<string>", position 0

If there's some flag inside PyYAML that can be used to allow them, I think yamllint should activate it to allow it to lint the widest possible range of yaml files.

@adrienverge
Copy link
Owner

Thanks for reporting this!

I think it's related to yaml/pyyaml#25
Any hint or help is welcome.

I'm curious about where you found emojis in YAML?

@adamchainz
Copy link
Contributor Author

Writing cloudformation templates and someone tried to add 🤷‍♂️ in a comment.

@jayvdb
Copy link
Contributor

jayvdb commented Mar 21, 2018

The fix in PyYAML has been merged, but they dont release yet, and havent for a long time. A bit of discussion regarding releasing at yaml/pyyaml#46

Maybe switch to using ruamel.yaml ; if so need to be careful about requiring the newish version.

@j-mie
Copy link

j-mie commented Feb 14, 2019

This is unfortunately still an issue on 1.15.0, are there any plans to fix this? Happy to submit a PR switching to ruamel.yaml if that's of use?

@phpdev
Copy link

phpdev commented Mar 13, 2019

I have same issue. Is there any solution?

@adrienverge
Copy link
Owner

PyYAML 5.1 was just released, so the bug should be fixed now (by yaml/pyyaml#63).

Could you test with this new version?

@adamchainz
Copy link
Contributor Author

My reported test case now passes, yay! Thanks for the update @adrienverge :)

@adrienverge
Copy link
Owner

I'm glad to hear it 🙂

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

5 participants