Correct cause of NPE in python wrapper
[ric-plt/lib/rmr.git] / src / bindings / rmr-python / rmr / rmr.py
index 00f6e71..9e45dd6 100644 (file)
@@ -69,7 +69,7 @@ def _get_mapping_dict(cache={}):
     RMR_ERR_TIMEOUT     12  message processing call timed out
     RMR_ERR_UNSET       13  the message hasn't been populated with a transport buffer
     RMR_ERR_TRUNC       14  received message likely truncated
-    RMR_ERR_INITFAILED  15  initialisation of something (probably message) failed
+    RMR_ERR_INITFAILED  15  initialization of something (probably message) failed
 
     """
     if cache:
@@ -105,11 +105,9 @@ _RCONST = _get_constants()
 # TODO: Are there others that will be useful?
 
 RMR_MAX_RCV_BYTES = _RCONST["RMR_MAX_RCV_BYTES"]
-
-RMRFL_NONE = _RCONST.get("RMRFL_MTCALL", 0x02)   # initialisation flags
+RMRFL_MTCALL = _RCONST.get("RMRFL_MTCALL", 0x02)  # initialization flags
 RMRFL_NONE = _RCONST.get("RMRFL_NONE", 0x0)
-
-RMR_OK = _RCONST["RMR_OK"]                        # useful state constants
+RMR_OK = _RCONST["RMR_OK"]  # useful state constants
 RMR_ERR_TIMEOUT = _RCONST["RMR_ERR_TIMEOUT"]
 RMR_ERR_RETRY = _RCONST["RMR_ERR_RETRY"]
 
@@ -439,11 +437,8 @@ def message_summary(ptr_mbuf):
     dict:
         dict message summary
     """
-    if ptr_mbuf.contents.len > RMR_MAX_RCV_BYTES:
-        return "Malformed message: message length is greater than the maximum possible"
-
     return {
-        "payload": get_payload(ptr_mbuf),
+        "payload": get_payload(ptr_mbuf) if ptr_mbuf.contents.state == RMR_OK else None,
         "payload length": ptr_mbuf.contents.len,
         "message type": ptr_mbuf.contents.mtype,
         "subscription id": ptr_mbuf.contents.sub_id,