tylerwince / flake8-bandit

Automated security testing using bandit and flake8.
MIT License
111 stars 23 forks source link

This plugin fails to parse files with unicode on windows #10

Closed sobolevn closed 5 years ago

sobolevn commented 5 years ago

Reproduction steps:

  1. Use windows
  2. Install flake8-bandit
  3. Create a python file with print('Привет, бандиты!') unicode contents
  4. Try to run flake8 your_file.py

It will fail with something like this:

c:\users\appveyor\appdata\local\pypoetry\cache\virtualenvs\wemake-python-styleguide-py3.6\lib\site-packages\flake8\checker.py:451: in run_check
    return plugin["plugin"](**arguments)
c:\users\appveyor\appdata\local\pypoetry\cache\virtualenvs\wemake-python-styleguide-py3.6\lib\site-packages\flake8_bandit.py:35: in __init__
    self._load_source()
c:\users\appveyor\appdata\local\pypoetry\cache\virtualenvs\wemake-python-styleguide-py3.6\lib\site-packages\flake8_bandit.py:73: in _load_source
    self.source = f.read()
C:\Python36\lib\encodings\cp1252.py:23: in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
E   UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 14170: character maps to <undefined>

Original issue: https://github.com/wemake-services/wemake-python-styleguide/issues/337 Log: https://ci.appveyor.com/project/wemake-services/wemake-python-styleguide/build/job/185lp386ce91jtsy

tylerwince commented 5 years ago

This is something that I need to work on for sure -- I will potentially have some time in the coming weeks but would welcome a PR if you want to take a stab at it

gdude2002 commented 5 years ago

I'm not sure when exactly this was fixed, but it does appear to no longer be a problem on the latest version.

tylerwince commented 5 years ago

Awesome! Not sure who fixed it, but probably wasn't me 😆

Let me know if you see it again @gdude2002