linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: Athira Rajeev <atrajeev@linux.vnet.ibm.com>,
	acme@kernel.org, jolsa@kernel.org, irogers@google.com,
	namhyung@kernel.org
Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	linuxppc-dev@lists.ozlabs.org, akanksha@linux.ibm.com,
	maddy@linux.ibm.com, kjain@linux.ibm.com,
	disgoel@linux.vnet.ibm.com
Subject: Re: [PATCH 2/2] tools/perf: Fix parallel-perf python script to replace new python syntax ":=" usage
Date: Sun, 16 Jun 2024 18:03:28 +0300	[thread overview]
Message-ID: <802a5260-8d74-4a5e-85fc-c9b86460d4c5@intel.com> (raw)
In-Reply-To: <20240614172742.56976-2-atrajeev@linux.vnet.ibm.com>

On 14/06/24 20:27, Athira Rajeev wrote:
> 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

According to below python 3.6 is end-of-life

	https://devguide.python.org/versions/

What was still using 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
> 
> Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>

Acked-by: Adrian Hunter <adrian.hunter@intel.com>

> ---
>  tools/perf/scripts/python/parallel-perf.py | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/perf/scripts/python/parallel-perf.py b/tools/perf/scripts/python/parallel-perf.py
> index 21f32ec5ed46..be85fd7f6632 100755
> --- a/tools/perf/scripts/python/parallel-perf.py
> +++ b/tools/perf/scripts/python/parallel-perf.py
> @@ -439,7 +439,8 @@ def ProcessCommandOutputLines(cmd, per_cpu, fn, *x):
>  	pat = re.compile(r"\s*\[[0-9]+\]")
>  	p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
>  	while True:
> -		if line := p.stdout.readline():
> +		line = p.stdout.readline()
> +		if line:
>  			line = line.decode("utf-8")
>  			if pat.match(line):
>  				line = line.split()


  reply	other threads:[~2024-06-16 15:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-14 17:27 [PATCH 1/2] tools/perf: Fix the string match for "/tmp/perf-$PID.map" files in dso__load Athira Rajeev
2024-06-14 17:27 ` [PATCH 2/2] tools/perf: Fix parallel-perf python script to replace new python syntax ":=" usage Athira Rajeev
2024-06-16 15:03   ` Adrian Hunter [this message]
2024-06-17  9:02     ` Athira Rajeev
2024-06-16 15:37 ` [PATCH 1/2] tools/perf: Fix the string match for "/tmp/perf-$PID.map" files in dso__load Adrian Hunter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=802a5260-8d74-4a5e-85fc-c9b86460d4c5@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=acme@kernel.org \
    --cc=akanksha@linux.ibm.com \
    --cc=atrajeev@linux.vnet.ibm.com \
    --cc=disgoel@linux.vnet.ibm.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=kjain@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=namhyung@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).