[U-Boot] [PATCHv2 06/13] test/py: Manual python3 fixes

Stephen Warren swarren at wwwdotorg.org
Wed Oct 23 18:50:12 UTC 2019


On 10/22/19 9:20 PM, Tom Rini wrote:
> - Modern pytest is more visible in telling us about parameters that we
>    had not described, so describe a few more.
> - ConfigParser.readfp(...) is now configparser.read_file(...)
> - As part of the "strings vs bytes" conversions in Python 3, we use the
>    default encoding/decoding of utf-8 but in some places tell Python to
>    replace problematic conversions rather than throw a fatal error.
> - Fix a typo noticed while doing the above ("tot he" -> "to the").
> - As suggested by Stephen, re-alphabetize the import list
> - Per Heinrich, replace how we write contents in test_fit.py

> diff --git a/test/py/multiplexed_log.py b/test/py/multiplexed_log.py

> @@ -133,7 +134,7 @@ class RunAndLog(object):
>           self.logfile.write(self, msg)
>   
>           try:
> -            p = subprocess.Popen(cmd, cwd=cwd,
> +            p = subprocess.Popen(cmd, cwd=cwd, encoding="utf-8",

The encoding parameter was added in Python 3.6, so this change causes 
test.py to crash for me (with Python 3.5.2). The following will fix that:

>             p = subprocess.Popen(cmd, cwd=cwd,
>                 stdin=None, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
>             (stdout, stderr) = p.communicate()
>             if stdout is not None:
>                 stdout = stdout.decode('utf-8')
>             if stderr is not None:
>                 stderr = stderr.decode('utf-8')

I also noticed that a variety of strings in these patches use "" not '' 
in at least this patch. When I first wrote test/py, Simon made me go 
through everything and replace "" with '', so we should probably make 
new code follow the convention of using ''.


More information about the U-Boot mailing list