From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63CF26F2F2 for ; Thu, 5 Feb 2026 12:08:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770293327; cv=none; b=Xmo5z9pgr16GEsNxPgBmyljlmN0luziJ1RnSxoXRvzgAhdrjil+EqWtGSDTF4Z2EYlfFLPiLwiOxU+BuT9XTejTF98CFfNbXGGa0FavmMK8IqVUlXJSk/cbdCkUrhWbCrl4ebfCpUTa0AlEA0afuhJ/P17Yqp6HuiDNxzEV/vr4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770293327; c=relaxed/simple; bh=lF+ifxsI9p1x7q6u88VjzIf4sGXCH1orLW5RIRRZ7nw=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=cTmnkuU1e58DqMbhDvmc/lCBTbgqeceOPLrnOpv3zqr9t+Za/KPTPnNwem6RafE8OhNeBa6XoKlppk/sTm7ToTjfk/R4P7YQigd/rKWjknYJcAKXFTmSrRM26msOVO7Gj5wYFELNWe6R2gzOEJvhRwHvB9FIUUhZqt46Cu3/AxY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=SLQHvc7y; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=jsrsvJO2; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="SLQHvc7y"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="jsrsvJO2" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770293326; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=lF+ifxsI9p1x7q6u88VjzIf4sGXCH1orLW5RIRRZ7nw=; b=SLQHvc7yPs7ko/xYIV7tYLCRkXIUf/yhd2gbG9xYUdls4jwGXPGgPzpcTsd+VS3iTcOotc +NKfl62zefNO3RueUsA6w17Kbz+HnAJmw38cmTyN9Z4i/QhHyrw3FArdu9nUFDK8hssNk1 Ofiu8rYT9B8u0oOvcQ3Kx9FdVhWCrV0= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-63-FosJ_RCJOyGNX93LidanEg-1; Thu, 05 Feb 2026 07:08:44 -0500 X-MC-Unique: FosJ_RCJOyGNX93LidanEg-1 X-Mimecast-MFC-AGG-ID: FosJ_RCJOyGNX93LidanEg_1770293324 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-435db9425ebso976852f8f.1 for ; Thu, 05 Feb 2026 04:08:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1770293323; x=1770898123; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:autocrypt :references:in-reply-to:date:cc:to:from:subject:message-id:from:to :cc:subject:date:message-id:reply-to; bh=lF+ifxsI9p1x7q6u88VjzIf4sGXCH1orLW5RIRRZ7nw=; b=jsrsvJO26FS6UPXWuRiwfsHtbMEQ2iTWo5Ph+JE4TxsJTe6irroXkz82/SZgw44XjT 61BY2bmwmE/XsCkI/3QPvhY3BZGK6oMBYwno6vqImcprM3asMmoqvXhOI9kRLzQkUqA6 DKyJVloLNVVj20xUOmFKTaD7wCQSNTBQKzovxOl1EfOfcS5a3nXdNHvXcjKHiHbOOtvF eUWN2K3W7L1dfGuTG+1bcLK+fHTYa+Hot2F1rCy+YJx9J+94Wco3Gy2DKmpSrDYv4Bh7 QM+t1/5R5XiuDDZe/2OSOLB8XjmHO/eyX8OFyK7Ax4W57otDguvSZVIN32yh9I7jUXrf X2Zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770293323; x=1770898123; h=mime-version:user-agent:content-transfer-encoding:autocrypt :references:in-reply-to:date:cc:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=lF+ifxsI9p1x7q6u88VjzIf4sGXCH1orLW5RIRRZ7nw=; b=uC/zOOPKA+P7TEeaCYw0nJt/hKAp0EYRavt9O/UNNUcrdu2Fx2wFQSj/7mCcuZFyOg Gm2Lr5hqDaROq3ZgpjwnVefg0EqudbOJaJcUEeJP52C9XuDe/T4UovCn3KSZrorlT7B3 9ExDz0Zn3smrE7zQdUI2LN3QxWhoK18pC8vXQw3nrPFoklQzo4cIemVadmZPLK8QCFcE rXsc1FQybvWRyfu9M1tNoAWM75zOXgHwZTDaODW6iWWqrI3/DmBtTY64N8JW3acqrOnE 5TFR2ktK669GAX931c9tFOhee8Vj4tPKaTFAOenEFuW2ICaiI9TAF+Zmm35I1RL4F2BF f7jw== X-Forwarded-Encrypted: i=1; AJvYcCUInjAkl8RndTQWqrSFMP17YbNdu6gFqVQVT+ovmVgeyk9t1taVCCVCUhWtEORFaUbyy2agPuJ5tbdJ4nw=@vger.kernel.org X-Gm-Message-State: AOJu0YyVIATUPilYovk/oOh58xFXFYDye/pwNMlmS+oCu/UAz+DJLVPE oMRjZEVqILxRDuRp0es2a9WxNTgcFBjQ518NToEEBZgYybBHIaS1xAKFfL26Ye1hkZv82ihc0NH LylDiIkWvw1By1Ai/qrV+OQ4eJzPKR3Ocjw2ySRD1x7V1jPxGBohnVxw1nzzmqRAa1g== X-Gm-Gg: AZuq6aLdGqDrg4h0RfPlb16tNfB3gMpGL1oYL1xkOYJE6pwXRMOhoXxyHhT0lswe44w o9Bo+NSU5sjsxDTXvGekunw2EbytIg+hAWbCFgCIJoI8y/wwhjal8T6BKnasS5qWeVR7ef4GXeb 3CfsP2uo0CgQF/575wHxAE6pb9/qK1ZqZLcVftXiXliqFsy7v/uJMKZ7c7TgA1//J74RneIP4um FQ5U6iQs1nPSMonadz1mvPkWyYrd7dpFljWwCLrb9wG2FtfYTF2S41NMGN3Wz50IyEw4qejHmfG 47d2gUBMI6Oqari/9vh3JlJs8mN0NCTMKHpisR5R036lcaB12KGO9T9vd4vL6+bSdV5pdt0CGCl M2qjEuVdalzowlzNG4WawmmJsD8Jt8ZWGxKYzdTOpTCfp+myNLVDm2f6X3DBEbwRoJtgqV5LZAL vM/ZX57udM X-Received: by 2002:a05:6000:40c8:b0:430:ff8b:fdc2 with SMTP id ffacd0b85a97d-4361805fc02mr9780061f8f.60.1770293323510; Thu, 05 Feb 2026 04:08:43 -0800 (PST) X-Received: by 2002:a05:6000:40c8:b0:430:ff8b:fdc2 with SMTP id ffacd0b85a97d-4361805fc02mr9780022f8f.60.1770293323075; Thu, 05 Feb 2026 04:08:43 -0800 (PST) Received: from gmonaco-thinkpadt14gen3.rmtit.csb (185-132-178-103.hosted-by-worldstream.net. [185.132.178.103]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43617e3a546sm15995841f8f.17.2026.02.05.04.08.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Feb 2026 04:08:42 -0800 (PST) Message-ID: Subject: Re: [PATCH v2 01/20] rv/rvgen: introduce AutomataError exception class From: Gabriele Monaco To: Wander Lairson Costa Cc: Steven Rostedt , Nam Cao , "open list:RUNTIME VERIFICATION (RV)" , open list Date: Thu, 05 Feb 2026 13:08:41 +0100 In-Reply-To: <20260204144914.104028-2-wander@redhat.com> References: <20260204144914.104028-1-wander@redhat.com> <20260204144914.104028-2-wander@redhat.com> Autocrypt: addr=gmonaco@redhat.com; prefer-encrypt=mutual; keydata=mDMEZuK5YxYJKwYBBAHaRw8BAQdAmJ3dM9Sz6/Hodu33Qrf8QH2bNeNbOikqYtxWFLVm0 1a0JEdhYnJpZWxlIE1vbmFjbyA8Z21vbmFjb0BrZXJuZWwub3JnPoiZBBMWCgBBFiEEysoR+AuB3R Zwp6j270psSVh4TfIFAmjKX2MCGwMFCQWjmoAFCwkIBwICIgIGFQoJCAsCBBYCAwECHgcCF4AACgk Q70psSVh4TfIQuAD+JulczTN6l7oJjyroySU55Fbjdvo52xiYYlMjPG7dCTsBAMFI7dSL5zg98I+8 cXY1J7kyNsY6/dcipqBM4RMaxXsOtCRHYWJyaWVsZSBNb25hY28gPGdtb25hY29AcmVkaGF0LmNvb T6InAQTFgoARAIbAwUJBaOagAULCQgHAgIiAgYVCgkICwIEFgIDAQIeBwIXgBYhBMrKEfgLgd0WcK eo9u9KbElYeE3yBQJoymCyAhkBAAoJEO9KbElYeE3yjX4BAJ/ETNnlHn8OjZPT77xGmal9kbT1bC1 7DfrYVISWV2Y1AP9HdAMhWNAvtCtN2S1beYjNybuK6IzWYcFfeOV+OBWRDQ== Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.58.2 (3.58.2-1.fc43) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Wed, 2026-02-04 at 11:42 -0300, Wander Lairson Costa wrote: > Replace the generic except Exception block with a custom AutomataError > class that inherits from Exception. This provides more precise exception > handling for automata parsing and validation errors while avoiding > overly broad exception catches that could mask programming errors like > SyntaxError or TypeError. >=20 > The AutomataError class is raised when DOT file processing fails due to > invalid format, I/O errors, or malformed automaton definitions. The > main entry point catches this specific exception and provides a > user-friendly error message to stderr before exiting. >=20 > Signed-off-by: Wander Lairson Costa [...] > --- > @@ -45,8 +52,8 @@ class Automata: > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 dot_lines =3D [] > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 try: > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = dot_file =3D open(self.__dot_path) > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 except: > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 raise= Exception("Cannot open the file: %s" % self.__dot_path) > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 except OSError as exc: > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 raise= AutomataError(f"Cannot open the file: {self.__dot_path}") > from exc >=20 You probably don't want to mask all OSError in main.py and allow only this = one. I think it's alright to=C2=A0keep a simpler message for wrong model file (a= lso LTL!), while throwing a splat in other cases (e.g. missing templates). But wouldn't it be better to show the error message of the OSError? 99% of = the time it's going to be ENOENT, but could also be some EPERM or who knows wha= t. I'm fine keeping AutomataError here but would at least propagate the error message. Or keep it simple and catch all OSError as well, this one included. Thanks, Gabriele > =C2=A0 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 dot_lines =3D dot_file.r= ead().splitlines() > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 dot_file.close() > @@ -55,7 +62,7 @@ class Automata: > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 line =3D dot_lines[curso= r].split() > =C2=A0 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (line[0] !=3D "digrap= h") and (line[1] !=3D "state_automaton"): > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 raise= Exception("Not a valid .dot format: %s" % self.__dot_path) > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 raise= AutomataError("Not a valid .dot format: %s" % > self.__dot_path) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 else: > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = cursor +=3D 1 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return dot_lines > diff --git a/tools/verification/rvgen/rvgen/dot2c.py > b/tools/verification/rvgen/rvgen/dot2c.py > index 06a26bf15a7e9..74147ae2942f9 100644 > --- a/tools/verification/rvgen/rvgen/dot2c.py > +++ b/tools/verification/rvgen/rvgen/dot2c.py > @@ -13,7 +13,7 @@ > =C2=A0# For further information, see: > =C2=A0#=C2=A0=C2=A0 Documentation/trace/rv/deterministic_automata.rst > =C2=A0 > -from .automata import Automata > +from .automata import Automata, AutomataError > =C2=A0 > =C2=A0class Dot2c(Automata): > =C2=A0=C2=A0=C2=A0=C2=A0 enum_suffix =3D "" > @@ -71,7 +71,7 @@ class Dot2c(Automata): > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = min_type =3D "unsigned int" > =C2=A0 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if self.states.__len__()= > 1000000: > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 raise= Exception("Too many states: %d" % self.states.__len__()) > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 raise= AutomataError("Too many states: %d" % > self.states.__len__()) > =C2=A0 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return min_type > =C2=A0 > diff --git a/tools/verification/rvgen/rvgen/generator.py > b/tools/verification/rvgen/rvgen/generator.py > index 3441385c11770..a7bee6b1ea70c 100644 > --- a/tools/verification/rvgen/rvgen/generator.py > +++ b/tools/verification/rvgen/rvgen/generator.py > @@ -51,10 +51,7 @@ class RVGenerator: > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 raise FileNotFoundError(= "Could not find the rv directory, do you have > the kernel source installed?") > =C2=A0 > =C2=A0=C2=A0=C2=A0=C2=A0 def _read_file(self, path): > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 try: > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 fd = =3D open(path, 'r') > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 except OSError: > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 raise= Exception("Cannot open the file: %s" % path) > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 fd =3D open(path, 'r') > =C2=A0 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 content =3D fd.read() > =C2=A0 > @@ -65,7 +62,7 @@ class RVGenerator: > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 try: > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = path =3D os.path.join(self.abs_template_dir, file) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = return self._read_file(path) > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 except Exception: > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 except OSError: > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = # Specific template file not found. Try the generic template file > in the template/ > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = # directory, which is one level up > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = path =3D os.path.join(self.abs_template_dir, "..", file)