From 20e9f1ec80889ede2bd5a2d71536ae68b15a8786 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Fri, 4 Aug 2023 09:08:54 -0600 Subject: More conversions: {repr(var)} -> {var!r} Some of these got done in the tool conversion, some not, so picked up the rest manually. Signed-off-by: Mats Wichmann --- SCons/Tool/MSCommon/MSVC/ScriptArguments.py | 4 ++-- testing/framework/TestCmd.py | 8 ++++---- testing/framework/TestCommon.py | 12 ++++++------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/SCons/Tool/MSCommon/MSVC/ScriptArguments.py b/SCons/Tool/MSCommon/MSVC/ScriptArguments.py index 107e05b..8848095 100644 --- a/SCons/Tool/MSCommon/MSVC/ScriptArguments.py +++ b/SCons/Tool/MSCommon/MSVC/ScriptArguments.py @@ -235,7 +235,7 @@ def _user_script_argument_uwp(env, uwp, user_argstr) -> bool: if len(matches) > 1: debug('multiple uwp declarations: MSVC_SCRIPT_ARGS=%s', repr(user_argstr)) - err_msg = f"multiple uwp declarations: MSVC_SCRIPT_ARGS={repr(user_argstr)}" + err_msg = f"multiple uwp declarations: MSVC_SCRIPT_ARGS={user_argstr!r}" raise MSVCArgumentError(err_msg) if not uwp: @@ -270,7 +270,7 @@ def _msvc_script_argument_sdk_constraints(msvc, sdk_version): return None debug('invalid: method exit: sdk_version=%s', repr(sdk_version)) - err_msg = f"MSVC_SDK_VERSION ({repr(sdk_version)}) is not supported" + err_msg = f"MSVC_SDK_VERSION ({sdk_version!r}) is not supported" return err_msg def _msvc_script_argument_sdk_platform_constraints(msvc, toolset, sdk_version, platform_def): diff --git a/testing/framework/TestCmd.py b/testing/framework/TestCmd.py index 723b9ec..48238a0 100644 --- a/testing/framework/TestCmd.py +++ b/testing/framework/TestCmd.py @@ -722,9 +722,9 @@ def diff_re(a, b, fromfile: str='', tofile: str='', raise re.error(msg % (repr(s), e.args[0])) if not expr.search(bline): result.append(f"{i + 1}c{i + 1}") - result.append(f"< {repr(a[i])}") + result.append(f"< {a[i]!r}") result.append('---') - result.append(f"> {repr(b[i])}") + result.append(f"> {b[i]!r}") return result @@ -1672,7 +1672,7 @@ class TestCmd: except subprocess.TimeoutExpired: p.terminate() stdout, stderr = p.communicate() - + # this is instead of using Popen as a context manager: if p.stdout: p.stdout.close() @@ -1683,7 +1683,7 @@ class TestCmd: p.stdin.close() finally: p.wait() - + self.status = p.returncode self.process = None diff --git a/testing/framework/TestCommon.py b/testing/framework/TestCommon.py index b0879a6..993dc02 100644 --- a/testing/framework/TestCommon.py +++ b/testing/framework/TestCommon.py @@ -369,7 +369,7 @@ class TestCommon(TestCmd): title = 'output' sys.stdout.write(f"Missing expected lines from {title}:\n") for line in missing: - sys.stdout.write(f" {repr(line)}\n") + sys.stdout.write(f" {line!r}\n") sys.stdout.write(f"{self.banner(f'{title} ')}\n") sys.stdout.write(output) self.fail_test() @@ -396,7 +396,7 @@ class TestCommon(TestCmd): title = 'output' sys.stdout.write(f"Unexpected number of lines from {title}:\n") for line in counts: - sys.stdout.write(f" {repr(line)}: found {str(counts[line])}\n") + sys.stdout.write(f" {line!r}: found {str(counts[line])}\n") sys.stdout.write(f"{self.banner(f'{title} ')}\n") sys.stdout.write(output) self.fail_test() @@ -420,7 +420,7 @@ class TestCommon(TestCmd): title = 'output' sys.stdout.write(f"Missing any expected line from {title}:\n") for line in lines: - sys.stdout.write(f" {repr(line)}\n") + sys.stdout.write(f" {line!r}\n") sys.stdout.write(f"{self.banner(f'{title} ')}\n") sys.stdout.write(output) self.fail_test() @@ -463,12 +463,12 @@ class TestCommon(TestCmd): if missing: sys.stdout.write(f"Missing expected lines from {title}:\n") for line in missing: - sys.stdout.write(f" {repr(line)}\n") + sys.stdout.write(f" {line!r}\n") sys.stdout.write(f"{self.banner(f'Missing {title} ')}\n") if out: sys.stdout.write(f"Extra unexpected lines from {title}:\n") for line in out: - sys.stdout.write(f" {repr(line)}\n") + sys.stdout.write(f" {line!r}\n") sys.stdout.write(f"{self.banner(f'Extra {title} ')}\n") sys.stdout.flush() self.fail_test() @@ -582,7 +582,7 @@ class TestCommon(TestCmd): title = 'output' sys.stdout.write(f"Unexpected lines in {title}:\n") for line in unexpected: - sys.stdout.write(f" {repr(line)}\n") + sys.stdout.write(f" {line!r}\n") sys.stdout.write(f"{self.banner(f'{title} ')}\n") sys.stdout.write(output) self.fail_test() -- cgit v0.12