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

UnicodeDecodeError: flake8_mock.py, line 40, file_to_check.read() #8

Open
5j9 opened this issue Dec 5, 2017 · 2 comments
Open

UnicodeDecodeError: flake8_mock.py, line 40, file_to_check.read() #8

5j9 opened this issue Dec 5, 2017 · 2 comments

Comments

@5j9
Copy link

5j9 commented Dec 5, 2017

$ flake8.exe
Traceback (most recent call last):
  File "...\python36\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "...\python36\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "...\Python36\Scripts\flake8.exe\__main__.py", line 9, in <module>
  File "...\python36\lib\site-packages\flake8\main\cli.py", line 16, in main
    app.run(argv)
  File "...\python36\lib\site-packages\flake8\main\application.py", line 396, in run
    self._run(argv)
  File "...\python36\lib\site-packages\flake8\main\application.py", line 384, in _run
    self.run_checks()
  File "...\python36\lib\site-packages\flake8\main\application.py", line 310, in run_checks
    self.file_checker_manager.run()
  File "...\python36\lib\site-packages\flake8_per_file_ignores.py", line 32, in run
    orig_run(self)
  File "...\python36\lib\site-packages\flake8\checker.py", line 321, in run
    self.run_serial()
  File "...\python36\lib\site-packages\flake8\checker.py", line 305, in run_serial
    checker.run_checks()
  File "...\python36\lib\site-packages\flake8\checker.py", line 579, in run_checks
    self.run_ast_checks()
  File "...\python36\lib\site-packages\flake8\checker.py", line 493, in run_ast_checks
    for (line_number, offset, text, check) in runner:
  File "...\python36\lib\site-packages\flake8_mock.py", line 40, in run
    node_ast = file_to_check.read()
  File "...\python36\lib\encodings\cp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 3603: character maps to <undefined>
@5j9
Copy link
Author

5j9 commented Dec 5, 2017

I solved my issue by using open(self.filename, 'r', errors='ignore') instead of open(self.filename, 'r') in line 39. But I'm not sure if this is the best way to do it. Alternatively, it seems that flake8 also provides some methods to register for desired data and maybe we can use those.

@karantan
Copy link
Collaborator

Is this still a problem?

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

2 participants