Files
poky/meta/lib/oeqa/utils/subprocesstweak.py
Peter Marko 1987d7943e oeqa: fix OETestCalledProcessError for check_output method
Per documentation, subprocess.CalledProcessError exception has stderr
filled out only for run method, it's None for check_output method.
So serialize it only if it's not None.

Avoids:
  File "<poky-dir>/meta/lib/oeqa/utils/subprocesstweak.py", line 15, in __str__
    s = s + "\nStandard Error: " + strify(self.stderr)
        ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
TypeError: can only concatenate str (not "NoneType") to str

(From OE-Core rev: d13f444468b4b10f913b3cf01d7d13ef9d42838e)

Signed-off-by: Peter Marko <peter.marko@siemens.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2025-08-04 18:04:04 +01:00

22 lines
638 B
Python

#
# Copyright OpenEmbedded Contributors
#
# SPDX-License-Identifier: MIT
#
import subprocess
class OETestCalledProcessError(subprocess.CalledProcessError):
def __str__(self):
def strify(o):
return o.decode("utf-8", errors="replace") if isinstance(o, bytes) else o
s = super().__str__()
s = s + "\nStandard Output: " + strify(self.output)
# stderr is not available for check_output method
if self.stderr != None:
s = s + "\nStandard Error: " + strify(self.stderr)
return s
def errors_have_output():
subprocess.CalledProcessError = OETestCalledProcessError