Refine message decode to utf-8
diff --git a/rocketmq/client.py b/rocketmq/client.py
index 873e0cb..f1db810 100644
--- a/rocketmq/client.py
+++ b/rocketmq/client.py
@@ -21,8 +21,10 @@
PY2 = sys.version_info[0] == 2
if PY2:
text_type = unicode
+ binary_type = str
else:
text_type = str
+ binary_type = bytes
SendResult = namedtuple('SendResult', ['status', 'msg_id', 'offset'])
@@ -69,7 +71,7 @@
def maybe_decode(val):
- if val:
+ if isinstance(val, binary_type):
return val.decode('utf-8')
diff --git a/rocketmq/exceptions.py b/rocketmq/exceptions.py
index 8ea4906..5beb83f 100644
--- a/rocketmq/exceptions.py
+++ b/rocketmq/exceptions.py
@@ -19,7 +19,7 @@
return
exc_cls = _EXCEPTION_MAP.get(status_code, RocketMQException)
msg = dll.GetLatestErrorMessage()
- if msg:
+ if msg is not None:
msg = msg.decode('utf-8')
msg = re.sub('<.*?(rocketmq-client-cpp/)(.*)>', '\\1\\2', msg)
if msg.startswith('msg: '):