BackgroundClient: implemented a solution to send data of types not supported by JSON.

Mon, 13 Apr 2020 11:30:24 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 13 Apr 2020 11:30:24 +0200
changeset 7534
5441fa55cb0d
parent 7533
88261c96484b
child 7535
dac9bc72a0f3

BackgroundClient: implemented a solution to send data of types not supported by JSON.

eric6/UI/data/codeDocumentationViewer_rc.py file | annotate | diff | comparison | revisions
eric6/Utilities/BackgroundClient.py file | annotate | diff | comparison | revisions
--- a/eric6/UI/data/codeDocumentationViewer_rc.py	Sun Apr 12 19:07:49 2020 +0200
+++ b/eric6/UI/data/codeDocumentationViewer_rc.py	Mon Apr 13 11:30:24 2020 +0200
@@ -2,7 +2,7 @@
 
 # Resource object code
 #
-# Created by: The Resource Compiler for PyQt5 (Qt v5.14.2)
+# Created by: The Resource Compiler for PyQt5 (Qt v5.14.1)
 #
 # WARNING! All changes made in this file will be lost!
 
@@ -228,9 +228,9 @@
 \x00\x00\x00\x00\x00\x02\x00\x00\x00\x02\x00\x00\x00\x01\
 \x00\x00\x00\x00\x00\x00\x00\x00\
 \x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\
-\x00\x00\x01\x71\x69\x48\x61\x0a\
+\x00\x00\x01\x71\x72\xc4\xcc\x71\
 \x00\x00\x00\x3e\x00\x01\x00\x00\x00\x01\x00\x00\x05\xef\
-\x00\x00\x01\x71\x69\x35\xae\xa0\
+\x00\x00\x01\x71\x72\xc4\xcc\x41\
 "
 
 qt_version = [int(v) for v in QtCore.qVersion().split('.')]
--- a/eric6/Utilities/BackgroundClient.py	Sun Apr 12 19:07:49 2020 +0200
+++ b/eric6/Utilities/BackgroundClient.py	Mon Apr 13 11:30:24 2020 +0200
@@ -80,6 +80,12 @@
         @param fn filename for identification (str)
         @param data return value(s) (any basic datatype)
         """
+        if not isinstance(data, (
+            dict, list, tuple, str, int, float, bool, type(None),
+        )):
+            # handle sending of objects of unsupported types
+            data = str(data)
+        
         packedData = json.dumps([fx, fn, data])
         if sys.version_info[0] >= 3:
             packedData = bytes(packedData, 'utf-8')

eric ide

mercurial