Fixes for Python3.6+ support

This commit is contained in:
Víctor Mayoral Vilches 2020-01-16 19:33:59 +01:00
parent 293ca17d82
commit 539b2d89d0
1 changed files with 8 additions and 5 deletions

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
"""flawfinder: Find potential security flaws ("hits") in source code. """flawfinder: Find potential security flaws ("hits") in source code.
Usage: Usage:
@ -418,9 +418,12 @@ class Hit(object):
# Show as CSV format # Show as CSV format
def show_csv(self): def show_csv(self):
csv_writer.writerow([ csv_writer.writerow([
self.filename, self.line, self.column, self.level, self.category, self.filename.encode('utf8'), self.line,
self.name, self.warning, self.suggestion, self.note, self.column, self.level,
self.cwes(), self.context_text, self.fingerprint() self.category.encode('utf8'), self.name.encode('utf8'),
self.warning.encode('utf8'), self.suggestion.encode('utf8'),
self.note.encode('utf8'), self.cwes().encode('utf8'),
self.context_text.encode('utf8'), self.fingerprint().encode('utf8')
]) ])
def show(self): def show(self):
@ -1485,7 +1488,7 @@ def process_c_file(f, patch_infos):
num_links_skipped += 1 num_links_skipped += 1
return return
try: try:
my_input = open(f, "r") my_input = open(f, "r", encoding="ISO-8859-1")
except BaseException: except BaseException:
print("Error: failed to open", h(f)) print("Error: failed to open", h(f))
sys.exit(14) sys.exit(14)