From 7c955618dd46c3ea7dc221bdf60354871f17f39d Mon Sep 17 00:00:00 2001 From: Dan Hawson <18214721+GertyP@users.noreply.github.com> Date: Sat, 29 Jul 2023 14:47:08 +0100 Subject: [PATCH] Rename variables that clash with pdb commands By default, pdb assumes that any command run is python code to be evaluated, but only if that code isn't a builtin pdb command. You can force it to be evaluated as python code by prefixing it with `!`. It's handy to simply name a python variable and have its variable be printed. But single letter variables like 's' and 'p' make debugging with pdb commands (i.e. 's'tep, and 'p'rint evaluated expressions) less convenient, and potentially confusing. --- unittests/allplatformstests.py | 4 ++-- unittests/baseplatformtests.py | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py index 5a6e88b1f..12eafd595 100644 --- a/unittests/allplatformstests.py +++ b/unittests/allplatformstests.py @@ -1369,8 +1369,8 @@ class AllPlatformTests(BasePlatformTests): targets = self.introspect('--targets') # This assumes all of the targets support lto for t in targets: - for s in t['target_sources']: - self.assertTrue(expected.issubset(set(s['parameters'])), f'Incorrect values for {t["name"]}') + for src in t['target_sources']: + self.assertTrue(expected.issubset(set(src['parameters'])), f'Incorrect values for {t["name"]}') def test_dist_git(self): if not shutil.which('git'): diff --git a/unittests/baseplatformtests.py b/unittests/baseplatformtests.py index 4b16e7d82..3008eb731 100644 --- a/unittests/baseplatformtests.py +++ b/unittests/baseplatformtests.py @@ -171,22 +171,22 @@ class BasePlatformTests(TestCase): env = os.environ.copy() env.update(override_envvars) - p = subprocess.run(command, stdout=subprocess.PIPE, - stderr=subprocess.STDOUT if stderr else subprocess.PIPE, - env=env, - encoding='utf-8', - text=True, cwd=workdir, timeout=60 * 5) + proc = subprocess.run(command, stdout=subprocess.PIPE, + stderr=subprocess.STDOUT if stderr else subprocess.PIPE, + env=env, + encoding='utf-8', + text=True, cwd=workdir, timeout=60 * 5) print('$', join_args(command)) print('stdout:') - print(p.stdout) + print(proc.stdout) if not stderr: print('stderr:') - print(p.stderr) - if p.returncode != 0: - if 'MESON_SKIP_TEST' in p.stdout: + print(proc.stderr) + if proc.returncode != 0: + if 'MESON_SKIP_TEST' in proc.stdout: raise SkipTest('Project requested skipping.') - raise subprocess.CalledProcessError(p.returncode, command, output=p.stdout) - return p.stdout + raise subprocess.CalledProcessError(proc.returncode, command, output=proc.stdout) + return proc.stdout def init(self, srcdir, *, extra_args=None,