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

Specify output_file encoding as utf-8 #364

Merged
merged 4 commits into from Dec 14, 2020
Merged

Conversation

Brcrwilliams
Copy link
Contributor

Fixes #362

Copy link
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.

@@ -215,7 +215,7 @@ def main():
)
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
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

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
Member

@daybarr looking to remove python2 now.

#584

Copy link
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