mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] perf python: Fix arm-cs-trace-disasm type error
@ 2026-09-28 12:58 James Clark
  2026-09-28 13:46 ` Leo Yan
  0 siblings, 1 reply; 5+ messages in thread
From: James Clark @ 2026-09-28 12:58 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Namhyung Kim, Ian Rogers, Leo Yan
  Cc: linux-perf-users, linux-kernel, James Clark

The perf sample dso_bid getter returns a string or None, matching its
Optional[str] annotation. Attempting to decode it as bytes causes mypy
to report union-attr errors, even though this was behind a conditional
that checked for bytes type.

Use the string directly, retaining the fallback for an unknown build ID.

This fixes the following build error:

  python/arm-cs-trace-disasm.py:266: error: Item "None" of "str | None" has no attribute "decode"  [union-attr]

Fixes: 279b402e5143 ("perf python: Port arm-cs-trace-disasm to perf module")
Assisted-by: Codex:GPT-6-Astra
Signed-off-by: James Clark <james.clark@linaro.org>
---
 tools/perf/python/arm-cs-trace-disasm.py | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/tools/perf/python/arm-cs-trace-disasm.py b/tools/perf/python/arm-cs-trace-disasm.py
index cf126ac79c18..1812ccaf4b20 100755
--- a/tools/perf/python/arm-cs-trace-disasm.py
+++ b/tools/perf/python/arm-cs-trace-disasm.py
@@ -263,9 +263,7 @@ class TraceDisasm:
 
         dso = getattr(sample, 'dso_long_name', None) or sample.dso or '[unknown]'
         symbol = sample.symbol or '[unknown]'
-        dso_bid = (sample.dso_bid.decode('utf-8')
-                   if isinstance(sample.dso_bid, bytes)
-                   else str(sample.dso_bid or '[unknown]'))
+        dso_bid = sample.dso_bid or '[unknown]'
         dso_start = sample.map_start
         dso_end = sample.map_end
         map_pgoff = sample.map_pgoff or 0

---
base-commit: 0ae6fc78c5ce0dfd18d8712a50f0fd4602eff103
change-id: 20260928-james-perf-mypy-cs-disasm-ed5ab0b60a8a

Best regards,
--  
James Clark <james.clark@linaro.org>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] perf python: Fix arm-cs-trace-disasm type error
  2026-09-28 12:58 [PATCH] perf python: Fix arm-cs-trace-disasm type error James Clark
@ 2026-09-28 13:46 ` Leo Yan
  2026-09-28 13:52   ` James Clark
  0 siblings, 1 reply; 5+ messages in thread
From: Leo Yan @ 2026-09-28 13:46 UTC (permalink / raw)
  To: James Clark
  Cc: Arnaldo Carvalho de Melo, Namhyung Kim, Ian Rogers,
	linux-perf-users, linux-kernel

On Mon, Sep 28, 2026 at 01:58:09PM +0100, James Clark wrote:
> The perf sample dso_bid getter returns a string or None, matching its
> Optional[str] annotation. Attempting to decode it as bytes causes mypy
> to report union-attr errors, even though this was behind a conditional
> that checked for bytes type.
> 
> Use the string directly, retaining the fallback for an unknown build ID.
> 
> This fixes the following build error:
> 
>   python/arm-cs-trace-disasm.py:266: error: Item "None" of "str | None" has no attribute "decode"  [union-attr]
> 
> Fixes: 279b402e5143 ("perf python: Port arm-cs-trace-disasm to perf module")
> Assisted-by: Codex:GPT-6-Astra
> Signed-off-by: James Clark <james.clark@linaro.org>

Thanks for the fix:

Reviewed-by: Leo Yan <leo.yan@arm.com>

Just curious, have you run this script and compare the result with old
one? Seems to me, the build pass is insufficient, we should run a small
test to ensure the result to keep same.

Thanks,
Leo

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] perf python: Fix arm-cs-trace-disasm type error
  2026-09-28 13:46 ` Leo Yan
@ 2026-09-28 13:52   ` James Clark
  2026-09-28 15:11     ` Ian Rogers
  2026-09-28 16:29     ` Arnaldo Carvalho de Melo
  0 siblings, 2 replies; 5+ messages in thread
From: James Clark @ 2026-09-28 13:52 UTC (permalink / raw)
  To: Leo Yan
  Cc: Arnaldo Carvalho de Melo, Namhyung Kim, Ian Rogers,
	linux-perf-users, linux-kernel



On 28/09/2026 14:46, Leo Yan wrote:
> On Mon, Sep 28, 2026 at 01:58:09PM +0100, James Clark wrote:
>> The perf sample dso_bid getter returns a string or None, matching its
>> Optional[str] annotation. Attempting to decode it as bytes causes mypy
>> to report union-attr errors, even though this was behind a conditional
>> that checked for bytes type.
>>
>> Use the string directly, retaining the fallback for an unknown build ID.
>>
>> This fixes the following build error:
>>
>>    python/arm-cs-trace-disasm.py:266: error: Item "None" of "str | None" has no attribute "decode"  [union-attr]
>>
>> Fixes: 279b402e5143 ("perf python: Port arm-cs-trace-disasm to perf module")
>> Assisted-by: Codex:GPT-6-Astra
>> Signed-off-by: James Clark <james.clark@linaro.org>
> 
> Thanks for the fix:
> 
> Reviewed-by: Leo Yan <leo.yan@arm.com>
> 
> Just curious, have you run this script and compare the result with old
> one? Seems to me, the build pass is insufficient, we should run a small
> test to ensure the result to keep same.
> 
> Thanks,
> Leo

Yep the test still passes. I assume the "if isinstance(sample.dso_bid, 
bytes)" part was just dead code.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] perf python: Fix arm-cs-trace-disasm type error
  2026-09-28 13:52   ` James Clark
@ 2026-09-28 15:11     ` Ian Rogers
  2026-09-28 16:29     ` Arnaldo Carvalho de Melo
  1 sibling, 0 replies; 5+ messages in thread
From: Ian Rogers @ 2026-09-28 15:11 UTC (permalink / raw)
  To: James Clark
  Cc: Leo Yan, Arnaldo Carvalho de Melo, Namhyung Kim,
	linux-perf-users, linux-kernel

On Mon, Sep 28, 2026 at 6:52 AM James Clark <james.clark@linaro.org> wrote:
>
>
>
> On 28/09/2026 14:46, Leo Yan wrote:
> > On Mon, Sep 28, 2026 at 01:58:09PM +0100, James Clark wrote:
> >> The perf sample dso_bid getter returns a string or None, matching its
> >> Optional[str] annotation. Attempting to decode it as bytes causes mypy
> >> to report union-attr errors, even though this was behind a conditional
> >> that checked for bytes type.
> >>
> >> Use the string directly, retaining the fallback for an unknown build ID.
> >>
> >> This fixes the following build error:
> >>
> >>    python/arm-cs-trace-disasm.py:266: error: Item "None" of "str | None" has no attribute "decode"  [union-attr]
> >>
> >> Fixes: 279b402e5143 ("perf python: Port arm-cs-trace-disasm to perf module")
> >> Assisted-by: Codex:GPT-6-Astra
> >> Signed-off-by: James Clark <james.clark@linaro.org>
> >
> > Thanks for the fix:
> >
> > Reviewed-by: Leo Yan <leo.yan@arm.com>
> >
> > Just curious, have you run this script and compare the result with old
> > one? Seems to me, the build pass is insufficient, we should run a small
> > test to ensure the result to keep same.
> >
> > Thanks,
> > Leo
>
> Yep the test still passes. I assume the "if isinstance(sample.dso_bid,
> bytes)" part was just dead code.

Sorry for the breakage!

Reviewed-by: Ian Rogers <irogers@google.com>

Thanks,
Ian

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] perf python: Fix arm-cs-trace-disasm type error
  2026-09-28 13:52   ` James Clark
  2026-09-28 15:11     ` Ian Rogers
@ 2026-09-28 16:29     ` Arnaldo Carvalho de Melo
  1 sibling, 0 replies; 5+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-09-28 16:29 UTC (permalink / raw)
  To: James Clark
  Cc: Leo Yan, Namhyung Kim, Ian Rogers, linux-perf-users, linux-kernel

On Mon, Sep 28, 2026 at 02:52:04PM +0100, James Clark wrote:
> On 28/09/2026 14:46, Leo Yan wrote:
> > On Mon, Sep 28, 2026 at 01:58:09PM +0100, James Clark wrote:
> > > The perf sample dso_bid getter returns a string or None, matching its
> > > This fixes the following build error:
> > >    python/arm-cs-trace-disasm.py:266: error: Item "None" of "str | None" has no attribute "decode"  [union-attr]
> > > Fixes: 279b402e5143 ("perf python: Port arm-cs-trace-disasm to perf module")
> > > Assisted-by: Codex:GPT-6-Astra
> > > Signed-off-by: James Clark <james.clark@linaro.org>

> > Thanks for the fix:
> > Reviewed-by: Leo Yan <leo.yan@arm.com>

> > Just curious, have you run this script and compare the result with old
> > one? Seems to me, the build pass is insufficient, we should run a small
> > test to ensure the result to keep same.
 
> Yep the test still passes. I assume the "if isinstance(sample.dso_bid,
> bytes)" part was just dead code.

Thanks, applied to perf-tools-next, for v7.4.

- Arnaldo

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-09-28 16:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-28 12:58 [PATCH] perf python: Fix arm-cs-trace-disasm type error James Clark
2026-09-28 13:46 ` Leo Yan
2026-09-28 13:52   ` James Clark
2026-09-28 15:11     ` Ian Rogers
2026-09-28 16:29     ` Arnaldo Carvalho de Melo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®