From 471d46d67e770ab06ab4f573cc9c2745b3a63a76 Mon Sep 17 00:00:00 2001 From: Mark Stenglein Date: Tue, 2 May 2017 23:41:31 -0400 Subject: [PATCH] web: __init__: _rep: Filter all bytes for serializer This commit fixes issue #2532 by filtering out any byte values added by any other extensions and decoding them to strings for the JSON serializer. It does not remove any of the keys, instead opting to just convert them. Signed-off-by: Mark Stenglein --- beetsplug/web/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/beetsplug/web/__init__.py b/beetsplug/web/__init__.py index 3c18ebd5d..1bea628f8 100644 --- a/beetsplug/web/__init__.py +++ b/beetsplug/web/__init__.py @@ -42,6 +42,10 @@ def _rep(obj, expand=False): else: del out['path'] + # Filter all bytes attributes and convert them to strings + for key in filter(lambda key: isinstance(out[key], bytes), out): + out[key] = out[key].decode('utf-8') + # Get the size (in bytes) of the backing file. This is useful # for the Tomahawk resolver API. try: