fail2ban-regex open files as utf-8 for python3

pull/128/merge^2
Steven Hiscocks 2013-02-24 18:59:07 +00:00
parent dbc40d6210
commit 418d845f9b
1 changed files with 4 additions and 1 deletions

View File

@ -346,7 +346,10 @@ if __name__ == "__main__":
if fail2banRegex.logIsFile(cmd_log): if fail2banRegex.logIsFile(cmd_log):
try: try:
hdlr = open(cmd_log) if sys.version_info >= (3,):
hdlr = open(cmd_log, encoding='utf-8', errors='ignore')
else:
hdlr = open(cmd_log)
print "Use log file : " + cmd_log print "Use log file : " + cmd_log
print print
for line in hdlr: for line in hdlr: