Fix decoding on "get_cnf --json"
[pyi2ncommon] / src / arnied_wrapper.py
index 713958f..73b242a 100644 (file)
@@ -472,6 +472,10 @@ def get_cnfvar(varname=None, instance=None, data=None, timeout=30, vm=None):
 
     # reading was successful, attempt to parse what we got
     try:
+        # The output from "get_cnf -j" is already utf-8. This contrast with
+        # the output of "get_cnf" (no json) which is latin1.
+        if isinstance(raw, bytes):
+            raw = raw.decode("utf-8")
         cnf = cnfvar.read_cnf_json(raw)
     except TypeError as exn:
         log.info("error \"%s\" parsing result of \"%s\"", exn, cmd_line)