Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'python/src/tcf/channel/__init__.py')
-rw-r--r--python/src/tcf/channel/__init__.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/python/src/tcf/channel/__init__.py b/python/src/tcf/channel/__init__.py
index dc040aa98..b66708adb 100644
--- a/python/src/tcf/channel/__init__.py
+++ b/python/src/tcf/channel/__init__.py
@@ -9,7 +9,7 @@
# * Wind River Systems - initial API and implementation
# *******************************************************************************
-import cStringIO, json, binascii, types, exceptions
+import cStringIO, json, binascii, types
# channel states
STATE_OPENING = 0
@@ -166,7 +166,7 @@ def fromJSONSequence(bytes):
def dumpJSONObject(object, buf):
json.dump(object, buf, separators=(',', ':'), cls=TCFJSONEncoder)
-
+
def toByteArray(data):
if data is None: return None
t = type(data)
@@ -175,12 +175,14 @@ def toByteArray(data):
return binascii.a2b_base64(data)
elif t is unicode:
return binascii.a2b_base64(str(data))
- raise exceptions.TypeError(str(t))
+ raise TypeError(str(t))
class TCFJSONEncoder(json.JSONEncoder):
def default(self, o):
if isinstance(o, bytearray):
return binascii.b2a_base64(o)[:-1]
+ elif hasattr(o, '__json__'):
+ return o.__json__()
elif hasattr(o, '__iter__'):
return tuple(o)
else:

Back to the top