Skip to content

Commit 17920a4

Browse files
committed
Decode UTF-8 with 'replace' option to avoid exceptions
To avoid generating an exception when receiving and trying to decode non- UTF-8 encoded text, use the decode 'replace' option -- this replaces all malformed encodings with uFFFD REPLACEMENT CHARACTER. This addresses issue #18 on github.
1 parent 517837d commit 17920a4

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

cothread/py23.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def auto_decode(result, func, args):
5050
if result is None:
5151
return result
5252
else:
53-
return result.decode('UTF-8')
53+
return result.decode('UTF-8', 'replace')
5454

5555
def decode(s):
56-
return s.decode('UTF-8')
56+
return s.decode('UTF-8', 'replace')

0 commit comments

Comments
 (0)