From 25151173e31413bff6ed36ae3fc48b8bca4f768b Mon Sep 17 00:00:00 2001 From: DeleteMetaInf <59761487+DeleteMetaInf@users.noreply.github.com> Date: Thu, 23 Nov 2023 17:13:54 +0100 Subject: [PATCH] Fix UnicodeDecodeError Fix by wagnerscastle: https://github.com/panyanyany/beeprint/issues/30 Fork with the fix here: https://github.com/DeleteMetaInf/beeprint Tested it, and it works. No longer causes a UnicodeDecodeError when trying to print a malformed Unicode string or a JSON stringified Python dict. --- beeprint/helpers/string.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beeprint/helpers/string.py b/beeprint/helpers/string.py index b8765a6..268c516 100644 --- a/beeprint/helpers/string.py +++ b/beeprint/helpers/string.py @@ -132,7 +132,7 @@ def break_string(s, width): if pyv == 3: # seg is the type of in py3 # seg is the type of in py2 - seg_list = [seg.decode('utf8') for seg in seg_list] + seg_list = [seg.decode('utf8', 'backslashreplace') for seg in seg_list] return seg_list