The get_cnf command returns its output already in utf-8 when the
json switch is enabled. However the module cnfvar assumes that
raw data is always latin1, which is the case most of the time
when using arnied commands. This patch decodes the data, as we
know it is utf-8, before calling read_cnf_json.
Another caveat however, when the language locale is set to "C"
(which is currently the standard for avocado) before vm sessions
are started, every output (latin1 or utf-8) containing non ascii
characters will have those characters omitted (not garbled,
simply missing).
# 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)