Skip to content

Commit 92cb5fa

Browse files
authored
Merge pull request #203 from querti/ignore-decoding-errors
Don't raise an error when a character cannot be encoded/decoded
2 parents ecb3dcd + 5749568 commit 92cb5fa

File tree

3 files changed

+2
-3
lines changed

3 files changed

+2
-3
lines changed

kobo/hub/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def task_log_json(request, id, log_name):
231231
next_poll = LOG_WATCHER_INTERVAL
232232

233233
if six.PY3:
234-
content = str(content, encoding="utf-8")
234+
content = str(content, encoding="utf-8", errors="replace")
235235

236236
result = {
237237
"new_offset": offset + len(content),

kobo/shortcuts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def save_to_file(filename, text, append=False, mode=0o644):
221221
else:
222222
fd = os.open(filename, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, mode)
223223
if not isinstance(text, bytes):
224-
text = bytes(text, encoding="utf-8")
224+
text = bytes(text, encoding="utf-8", errors="replace")
225225
os.write(fd, text)
226226
os.close(fd)
227227

test-requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
mock==2.0.0
22
pytest
33
pytest-env
4-
Django
54
koji
65
requests
76
requests_gssapi

0 commit comments

Comments
 (0)