You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ma...@apache.org on 2019/03/20 00:57:16 UTC
[incubator-superset] branch master updated: Handle memoryview like
bytes instances and decode bytes to utf8 (#7062)
This is an automated email from the ASF dual-hosted git repository.
maximebeauchemin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/master by this push:
new c1c8e50 Handle memoryview like bytes instances and decode bytes to utf8 (#7062)
c1c8e50 is described below
commit c1c8e503601831aa5eb5125bb521ecdd141a3425
Author: Ville Brofeldt <33...@users.noreply.github.com>
AuthorDate: Wed Mar 20 02:57:09 2019 +0200
Handle memoryview like bytes instances and decode bytes to utf8 (#7062)
---
superset/utils/core.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/superset/utils/core.py b/superset/utils/core.py
index 022e9c5..3b47298 100644
--- a/superset/utils/core.py
+++ b/superset/utils/core.py
@@ -328,6 +328,8 @@ def datetime_f(dttm):
def base_json_conv(obj):
+ if isinstance(obj, memoryview):
+ obj = obj.tobytes()
if isinstance(obj, numpy.int64):
return int(obj)
elif isinstance(obj, numpy.bool_):
@@ -340,11 +342,9 @@ def base_json_conv(obj):
return str(obj)
elif isinstance(obj, timedelta):
return str(obj)
- elif isinstance(obj, memoryview):
- return str(obj.tobytes(), 'utf8')
elif isinstance(obj, bytes):
try:
- return '{}'.format(obj)
+ return obj.decode('utf-8')
except Exception:
return '[bytes]'