2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-26 03:19:48 +00:00

Have stringify replace by default

This allows easier handling of invalid decode
data.
This commit is contained in:
Jarrod Johnson 2019-10-11 08:57:18 -04:00
parent c6255fa13b
commit eb48728bc1

View File

@ -31,7 +31,7 @@ def stringify(instr):
# Normalize unicode and bytes to 'str', correcting for
# current python version
if isinstance(instr, bytes) and not isinstance(instr, str):
return instr.decode('utf-8')
return instr.decode('utf-8', errors='replace')
elif not isinstance(instr, bytes) and not isinstance(instr, str):
return instr.encode('utf-8')
return instr