From c0508724584ab514c6041c92885b367347c9ad6c Mon Sep 17 00:00:00 2001 From: James Tanner Date: Mon, 2 Dec 2013 11:56:38 -0500 Subject: [PATCH] Fixes #4796 handle unicodedecode errors from dmidecode output --- library/system/setup | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/library/system/setup b/library/system/setup index 7b0fd70e80..353cf6f6d3 100755 --- a/library/system/setup +++ b/library/system/setup @@ -632,7 +632,13 @@ class LinuxHardware(Hardware): (rc, out, err) = module.run_command('%s -s %s' % (dmi_bin, v)) if rc == 0: # Strip out commented lines (specific dmidecode output) - self.facts[k] = ''.join([ line for line in out.split('\n') if not line.startswith('#') ]) + thisvalue = ''.join([ line for line in out.split('\n') if not line.startswith('#') ]) + try: + json.dumps(thisvalue) + except UnicodeDecodeError: + thisvalue = "NA" + + self.facts[k] = thisvalue else: self.facts[k] = 'NA' else: