perf test "perf script tests" fails as below in systems with python 3.6 File "/home/athira/linux/tools/perf/tests/shell/../../scripts/python/parallel-perf.py", line 442 if line := p.stdout.readline(): ^ SyntaxError: invalid syntax --- Cleaning up --- ---- end(-1) ---- 92: perf script tests: FAILED! This happens because ":=" is a new syntax that assigns values to variables as part of a larger expression. This is introduced from python 3.8 and hence fails in setup with python 3.6 Address this by splitting the large expression and check the value in two steps: Previous line: if line := p.stdout.readline(): Current change: line = p.stdout.readline() if line: With patch ./perf test "perf script tests" 93: perf script tests: Ok
Showing the changes to tools/perf/scripts/python (1 of 1 file). Show all
Unified · Split
| @@ -439,7 +439,8 @@ def ProcessCommandOutputLines(cmd, per_cpu, fn, *x): · 438 unmodified lines | ||
| 439 | 439 | pat = re.compile(r"\s*\[[0-9]+\]") |
| 440 | 440 | p = subprocess.Popen(cmd, stdout=subprocess.PIPE) |
| 441 | 441 | while True: |
| 442 | − if line := p.stdout.readline(): | |
| 442 | + line = p.stdout.readline() | |
| 443 | + if line: | |
| 443 | 444 | line = line.decode("utf-8") |
| 444 | 445 | if pat.match(line): |
| 445 | 446 | line = line.split() |