zupo / flake8-mock

Provides checking mock non-existent methods
GNU General Public License v2.0
16 stars 8 forks source link

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

Open 5j9 opened 6 years ago

5j9 commented 6 years ago
$ 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 commented 6 years ago

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 commented 1 year ago

Is this still a problem?