From: Tom Hromatka Date: Tue, 22 Feb 2022 23:08:43 +0000 (-0700) Subject: cgroup.py: Fix exception handling in init_cgrules() X-Git-Tag: v3.1.0~308^2~2^2~48 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e38a9658d94786995b6916dcc54e70850bddfda5;p=thirdparty%2Flibcgroup.git cgroup.py: Fix exception handling in init_cgrules() When /etc/cgconfig.d/ exists, a UnicodeDecodeError is thrown because the Unicode error string cannot be properly decoded by Run.run(). Catch this error as it's not an error in this case. Signed-off-by: Tom Hromatka --- diff --git a/ftests/cgroup.py b/ftests/cgroup.py index 041d7132..25d69141 100644 --- a/ftests/cgroup.py +++ b/ftests/cgroup.py @@ -608,14 +608,9 @@ class Cgroup(object): config.container.run(cmd, shell_bool=True) else: Run.run(cmd, shell_bool=True) - except RunError as re: - # check the errno to ensure the directory exists rather - # than receiving a different error - if re.ret == 1 and \ - 'File exists' in re.stderr: - pass - else: - raise re + except UnicodeDecodeError as ude: + # A unicode error is thrown when the directory already exists + pass cmd2 = list()