Skip to content

Commit 908b8dc

Browse files
committed
Merge pull request #2542 from ocelotsloth/2532-web-serializer-bytes
web: #2532 - Decode bytes values to strings
2 parents e7ea7ab + 22f07b9 commit 908b8dc

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

beetsplug/web/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from werkzeug.routing import BaseConverter, PathConverter
2626
import os
2727
import json
28+
import base64
2829

2930

3031
# Utilities.
@@ -42,6 +43,11 @@ def _rep(obj, expand=False):
4243
else:
4344
del out['path']
4445

46+
# Filter all bytes attributes and convert them to strings
47+
for key, value in out.items():
48+
if isinstance(out[key], bytes):
49+
out[key] = base64.b64encode(out[key]).decode('ascii')
50+
4551
# Get the size (in bytes) of the backing file. This is useful
4652
# for the Tomahawk resolver API.
4753
try:

0 commit comments

Comments
 (0)