|
From: Paul F. <pj...@wa...> - 2023-03-22 21:02:53
|
On 22-03-23 00:22, Nicholas Nethercote wrote: > I have merged the new version of `cg_annotate`: > https://sourceware.org/git/?p=valgrind.git;a=commit;h=4650b7949ae3a41326e52ae454a9202493c41444 <https://sourceware.org/git/?p=valgrind.git;a=commit;h=4650b7949ae3a41326e52ae454a9202493c41444> Hi Nick I've seen two problems. The first I've already fixed with "env". The other is with typing / TypeAlias. This was added in Python 3.10. On my FreeBSD system "python3" defaults to Python 3.9, so I get ImportError: cannot import name 'TypeAlias' from 'typing' (/usr/local/lib/python3.9/typing.py) That will probably also cause problems on old Linux systems as well. I don't know much Python, but would it be OK to use non-explicit (implicit?) type aliases like in the diff below: The alternative would be to add python3.10 detection, something like AC_CHECK_PROGS([PYTHON3],[python3.10 python3] and then to use @PYTHON3@ in cg_annotate.in and the 3 ann[123]/vgtest files. A+ Paul diff --git a/cachegrind/cg_annotate.in b/cachegrind/cg_annotate.in index 91d75aecd..c3d5f71d4 100755 --- a/cachegrind/cg_annotate.in +++ b/cachegrind/cg_annotate.in @@ -73,7 +73,7 @@ import re import sys from argparse import ArgumentParser, BooleanOptionalAction, Namespace from collections import defaultdict -from typing import Callable, DefaultDict, NewType, NoReturn, TextIO, TypeAlias +from typing import Callable, DefaultDict, NewType, NoReturn, TextIO class Args(Namespace): @@ -323,11 +323,11 @@ class Cc: Flfn = NewType("Flfn", tuple[str, str]) # Per-function CCs. -DictFlfnCc: TypeAlias = DefaultDict[Flfn, Cc] +DictFlfnCc = DefaultDict[Flfn, Cc] # Per-line CCs, organised by filename and line number. -DictLineCc: TypeAlias = DefaultDict[int, Cc] -DictFlDictLineCc: TypeAlias = DefaultDict[str, DictLineCc] +DictLineCc = DefaultDict[int, Cc] +DictFlDictLineCc = DefaultDict[str, DictLineCc] def die(msg: str) -> NoReturn: A+ Paul |