PyCQA / PyCQA/bandit

Failed to run on xarray

Open
#607 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
8.3k
Forks
835
Avg merge
5d 3h
Merged PRs (30d)
1

Description

Describe the bug
When running bandit on xarray on Windows conda environment, Python 3.8.1, bandit fails with error

Traceback (most recent call last):
  File "c:\apps\miniconda\envs\modin\lib\site-packages\bandit\core\manager.py", line 168, in output_results
    report_func(self, fileobj=output_file, sev_level=sev_level,
  File "c:\apps\miniconda\envs\modin\lib\site-packages\bandit\formatters\text.py", line 168, in report
    wrapped_file.write(utils.convert_file_contents(result))
  File "c:\apps\miniconda\envs\modin\lib\site-packages\colorama\ansitowin32.py", line 41, in write
    self.__convertor.write(text)
  File "c:\apps\miniconda\envs\modin\lib\site-packages\colorama\ansitowin32.py", line 162, in write
    self.write_and_convert(text)
  File "c:\apps\miniconda\envs\modin\lib\site-packages\colorama\ansitowin32.py", line 190, in write_and_convert
    self.write_plain_text(text, cursor, len(text))
  File "c:\apps\miniconda\envs\modin\lib\site-packages\colorama\ansitowin32.py", line 195, in write_plain_text
    self.wrapped.write(text[start:end])
  File "c:\apps\miniconda\envs\modin\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2202' in position 294918: character maps to <undefined>

During handling of the above exception, another exception occurred:

To Reproduce
Steps to reproduce the behavior:

  1. git clone https://github.com/pydata/xarray.git
  2. bandit -r . > log.txt
  3. See error

Expected behavior
Get log

Bandit version
bandit 1.6.2
python version = 3.8.1 (default, Mar 2 2020, 13:06:26) [MSC v.1916 64 bit (AMD64)]

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with core/manager.py at output_results, then follow formatters/text.py report and utils.convert_file_contents, as shown in the traceback. Reproduce with bandit -r . > log.txt on the xarray checkout under the stated Windows Python 3.8.1 environment; done means the command produces the log without the UnicodeEncodeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.