From 06c6867bfdeb9ddf2f4543921a2421d97c1f81f3 Mon Sep 17 00:00:00 2001 From: Pavel Tikhomirov Date: Wed, 20 Jun 2018 18:13:21 +0300 Subject: [PATCH] zdtm.py: ignore unicode encode errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We have a problem after commit 212e4c771a1b ("test: make zdtm.py python2/python3 compatible") when running tests on python2: https://ci.openvz.org/job/CRIU/job/CRIU-virtuozzo/job/criu-dev/3804/console Traceback (most recent call last): File "./test/zdtm.py", line 2249, in opts['action'](opts) File "./test/zdtm.py", line 2001, in run_tests launcher.run_test(t, tdesc, run_flavs) File "./test/zdtm.py", line 1680, in run_test self.wait() File "./test/zdtm.py", line 1737, in wait self.__wait_one(0) File "./test/zdtm.py", line 1725, in __wait_one print(open(sub['log']).read()) UnicodeEncodeError: 'ascii' codec can't encode character u'\u2018' in position 258: ordinal not in range(128) print does not like "‘" symbol in zdtm_static_cgroup04.log: ... rmdir: failed to remove ‘cgclean.sKFHLm/zdtmtst/special_prop_check’: No such file or directory Small reproducer: [snorch@snorch ~]$ cat test_ascii.py from __future__ import absolute_import, division, print_function, unicode_literals from builtins import (str, open, range, zip, int, input) f = open('./zdtm_static_cgroup04.log') s = f.read() print(s) [snorch@snorch ~]$ python test_ascii.py | grep "" Traceback (most recent call last): File "test_ascii.py", line 6, in print(s) UnicodeEncodeError: 'ascii' codec can't encode character u'\u2018' in position 258: ordinal not in range(128) So just ignore these quote symbol when printing logs. Signed-off-by: Pavel Tikhomirov Signed-off-by: Andrei Vagin --- test/zdtm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/zdtm.py b/test/zdtm.py index 2e093e597..c795490ae 100755 --- a/test/zdtm.py +++ b/test/zdtm.py @@ -1723,7 +1723,7 @@ class Launcher: print(testline, file=self.__file_report) if sub['log']: - print(open(sub['log']).read()) + print(open(sub['log']).read().encode('ascii', 'ignore')) os.unlink(sub['log']) return True