[CRIU] [PATCH] zdtm.py: ignore unicode encode errors

Andrew Vagin avagin at virtuozzo.com
Wed Jun 20 21:20:56 MSK 2018


Applied, thanks

On Wed, Jun 20, 2018 at 06:13:21PM +0300, Pavel Tikhomirov wrote:
> 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 <module>
>     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 at 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 at snorch ~]$ python test_ascii.py | grep ""
> Traceback (most recent call last):
>   File "test_ascii.py", line 6, in <module>
>     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 <ptikhomirov at virtuozzo.com>
> ---
>  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 @@ do_sbs = False
>  					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
> -- 
> 2.17.0
> 


More information about the CRIU mailing list