You need to sign in or sign up before continuing.
  • C
    avocado/utils/process.py: make CmdResult.std{out,err}_text smarter · 72bdab0f
    Cleber Rosa 提交于
    In situations where a user of the CmdResult class manually sets the
    stdout/stderr attributes to a string, instead of the recommended and
    documented content of type "bytes", it won't be possible to "decode"
    the bytes into a string of a given encoding, and we'll end up with
    a crash.
    
    Since the goal of std{out,err}_text is to return a text version
    of stdout, if itself already is of such a type, let's just return
    it.
    
    Additionally, if the data cannot be "decode()d", let's raise an
    explicit TypeError on this location, rather than later in the code
    when its value is attempted to be used.
    Signed-off-by: NCleber Rosa <crosa@redhat.com>
    72bdab0f
test_utils_process.py 12.5 KB