mirror of https://github.com/fail2ban/fail2ban
Merge pull request #723 from kwirk/decode-warning
ENH: Clearer warning with lines which failed to decode correctlypull/739/head
commit
98daa9d301
|
@ -790,8 +790,10 @@ class FileContainer:
|
||||||
try:
|
try:
|
||||||
line = line.decode(self.getEncoding(), 'strict')
|
line = line.decode(self.getEncoding(), 'strict')
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
logSys.warning("Error decoding line from '%s' with '%s': %s" %
|
logSys.warning(
|
||||||
(self.getFileName(), self.getEncoding(), `line`))
|
"Error decoding line from '%s' with '%s'. Continuing "
|
||||||
|
" to process line ignoring invalid characters: %r" %
|
||||||
|
(self.getFileName(), self.getEncoding(), line))
|
||||||
if sys.version_info >= (3,): # In python3, must be decoded
|
if sys.version_info >= (3,): # In python3, must be decoded
|
||||||
line = line.decode(self.getEncoding(), 'ignore')
|
line = line.decode(self.getEncoding(), 'ignore')
|
||||||
return line
|
return line
|
||||||
|
|
Loading…
Reference in New Issue