From: Michal Simek Date: Mon, 6 Aug 2018 12:42:19 +0200 Subject: [U-Boot] [PATCH v2 3/8] test/py: Import 'configparser' lower case to be python 3.x safe In-Reply-To: <20170914213450.28754-4-paul.burton@imgtec.com> References: <20170914213450.28754-1-paul.burton@imgtec.com> <20170914213450.28754-4-paul.burton@imgtec.com> Message-ID: <3942db1d-1f7d-c398-a32a-9d026e27fae8@xilinx.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 14.9.2017 23:34, Paul Burton wrote: > In python 3.x the configparser module is named with all lower case. > Import it as such in order to avoid errors when running on python 3.x, > and fall back to the CamelCase version in order to keep working with > python 2.x. > > Signed-off-by: Paul Burton > Reviewed-by: Stephen Warren > > --- > > Changes in v2: > - Import python 2.x ConfigParser as the python 3.x style configparser, rather than the other way around. > > test/py/conftest.py | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/test/py/conftest.py b/test/py/conftest.py > index ced96f1006..bf55bd3d13 100644 > --- a/test/py/conftest.py > +++ b/test/py/conftest.py > @@ -19,11 +19,15 @@ import os > import os.path > import pytest > from _pytest.runner import runtestprotocol > -import ConfigParser > import re > import StringIO > import sys > > +try: > + import configparser > +except: > + import ConfigParser as configparser > + > # Globals: The HTML log file, and the connection to the U-Boot console. > log = None > console = None > @@ -167,7 +171,7 @@ def pytest_configure(config): > with open(dot_config, 'rt') as f: > ini_str = '[root]\n' + f.read() > ini_sio = StringIO.StringIO(ini_str) > - parser = ConfigParser.RawConfigParser() > + parser = configparser.RawConfigParser() > parser.readfp(ini_sio) > ubconfig.buildconfig.update(parser.items('root')) > > I have bisect issue with test/py framework on my PC and I end up on this patch. Below is the issue I am getting. And here are my python version. [u-boot](test)$ python3 --version Python 3.4.3 [u-boot](test)$ python --version Python 2.7.6 [u-boot](test)$ which python /usr/bin/python Do you know what could be the issue? Thanks, Michal ===================================================================================================== FAILURES ====================================================================================================== _____________________________________________________________________________________________________ test_help _____________________________________________________________________________________________________ u_boot_console = def test_help(u_boot_console): """Test that the "help" command can be executed.""" > u_boot_console.run_command('help') test/py/tests/test_help.py:8: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ test/py/u_boot_console_base.py:181: in run_command self.logstream.write(self.prompt, implicit=True) test/py/multiplexed_log.py:65: in write self.logfile.write(self, data, implicit) test/py/multiplexed_log.py:688: in write self.f.write(self._escape(data)) test/py/multiplexed_log.py:335: in _escape c for c in data) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ .0 = data = ''.join((c in self._nonprint) and ('%%%02x' % ord(c)) or > c for c in data) E UnicodeDecodeError: 'ascii' codec can't decode byte 0x80 in position 32: ordinal not in range(128) test/py/multiplexed_log.py:335: UnicodeDecodeError =============================================================================================== 130 tests deselected ================================================================================================ ===================================================================================== 1 failed, 130 deselected in 7.32 seconds ======================================================================================