Skip to content

Failure to read file in 1.21.0 with Python 2.7 and non-ascii yaml files. #238

@spyoungtech

Description

Yamllint is now failing on files that linted successfully in previous versions. This happens in files that are not entirely ascii. With Python 3.x this issue does not occur.

I believe this is due to a change in cli.py where io.open is used instead of open.

Relevant Traceback:

 $ yamllint -c .lintConfig .
 Traceback (most recent call last):
   File "/usr/local/bin/yamllint", line 11, in <module>
     sys.exit(run())
   File "/usr/local/lib/python2.7/dist-packages/yamllint/cli.py", line 181, in run
     problems = linter.run(f, conf, filepath)
   File "/usr/local/lib/python2.7/dist-packages/yamllint/linter.py", line 237, in run
     content = input.read()
   File "/usr/lib/python2.7/encodings/ascii.py", line 26, in decode
     return codecs.ascii_decode(input, self.errors)[0]
 UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 132: ordinal not in range(128)

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions