Merge pull request #44536 from mcalmer/develop-handle-decode-error-in-cmd_run

ignore invalid characters when getting decoding error in cmd run
This commit is contained in:
Nicole Thomas 2017-12-04 16:11:07 -05:00 committed by GitHub
commit 31b65bde4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -589,11 +589,17 @@ def _run(cmd,
out = proc.stdout.decode(__salt_system_encoding__)
except AttributeError:
out = u''
except UnicodeDecodeError:
log.error('UnicodeDecodeError while decoding output of cmd {0}'.format(cmd))
out = proc.stdout.decode(__salt_system_encoding__, 'replace')
try:
err = proc.stderr.decode(__salt_system_encoding__)
except AttributeError:
err = u''
except UnicodeDecodeError:
log.error('UnicodeDecodeError while decoding error of cmd {0}'.format(cmd))
err = proc.stderr.decode(__salt_system_encoding__, 'replace')
if rstrip:
if out is not None: