Skip to content

Specify output_file encoding as utf-8#364

Merged
ericwb merged 4 commits into
PyCQA:masterfrom
Brcrwilliams:encoding
Dec 14, 2020
Merged

Specify output_file encoding as utf-8#364
ericwb merged 4 commits into
PyCQA:masterfrom
Brcrwilliams:encoding

Conversation

@Brcrwilliams
Copy link
Copy Markdown
Contributor

Fixes #362

Copy link
Copy Markdown
Member

@ericwb ericwb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will require a Py2.7 fix.

Comment thread bandit/cli/main.py
parser.add_argument(
'-o', '--output', dest='output_file', action='store', nargs='?',
type=argparse.FileType('w'), default=sys.stdout,
type=argparse.FileType('w', encoding='utf-8'), default=sys.stdout,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The encoding parameter wasn't added until Py3.4, but we still want to support Py2.7 at this point.

https://docs.python.org/3/library/argparse.html#filetype-objects

@daybarr
Copy link
Copy Markdown

daybarr commented Mar 4, 2020

Is python 2.7 support still required for bandit now that python 2.7 itself is no longer supported? I see some discussion of this on #500 but it doesn't seem resolved yet.

The #362 bug that this PR would fix is the first thing I hit while trying out bandit for the first time on a Windows project using python 3.7. We could look to make this fix py2 compatible as well, but if py2 support is to be dropped, there would be no gain from that complication.

@lukehinds
Copy link
Copy Markdown
Member

@daybarr looking to remove python2 now.

#584

Copy link
Copy Markdown
Member

@ericwb ericwb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that we have dropped py2.7, this fix is applicable.

@ericwb ericwb merged commit 306f6fc into PyCQA:master Dec 14, 2020
@ericwb ericwb added this to the Release 1.7.1 milestone Dec 14, 2020
mikespallino pushed a commit to mikespallino/bandit that referenced this pull request Aug 25, 2021
Co-authored-by: Eric Brown <ericwb@users.noreply.github.com>
Co-authored-by: Luke Hinds <7058938+lukehinds@users.noreply.github.com>
mikespallino pushed a commit to mikespallino/bandit that referenced this pull request Jan 7, 2022
Co-authored-by: Eric Brown <ericwb@users.noreply.github.com>
Co-authored-by: Luke Hinds <7058938+lukehinds@users.noreply.github.com>
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

Successfully merging this pull request may close these issues.

Reports that contain unicode will cause Bandit to crash

4 participants