Skip to content

Commit 3f305f8

Browse files
walacglemco
authored andcommitted
rv/rvgen: remove bare except clauses in generator
Remove bare except clauses from the generator module that were catching all exceptions including KeyboardInterrupt and SystemExit. This follows the same exception handling improvements made in the previous AutomataError commit and addresses PEP 8 violations. The bare except clause in __create_directory was silently catching and ignoring all errors after printing a message, which could mask serious issues. For __write_file, the bare except created a critical bug where the file variable could remain undefined if open() failed, causing a NameError when attempting to write to or close the file. These methods now let OSError propagate naturally, allowing callers to handle file system errors appropriately. This provides clearer error reporting and allows Python's exception handling to show complete stack traces with proper error types and locations. Signed-off-by: Wander Lairson Costa <wander@redhat.com> Reviewed-by: Nam Cao <namcao@linutronix.de> Reviewed-by: Gabriele Monaco <gmonaco@redhat.com> Link: https://lore.kernel.org/r/20260223162407.147003-3-wander@redhat.com Signed-off-by: Gabriele Monaco <gmonaco@redhat.com>
1 parent a115ee5 commit 3f305f8

1 file changed

Lines changed: 1 addition & 8 deletions

File tree

tools/verification/rvgen/rvgen/generator.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -198,17 +198,10 @@ def __create_directory(self):
198198
os.mkdir(path)
199199
except FileExistsError:
200200
return
201-
except:
202-
print("Fail creating the output dir: %s" % self.name)
203201

204202
def __write_file(self, file_name, content):
205-
try:
206-
file = open(file_name, 'w')
207-
except:
208-
print("Fail writing to file: %s" % file_name)
209-
203+
file = open(file_name, 'w')
210204
file.write(content)
211-
212205
file.close()
213206

214207
def _create_file(self, file_name, content):

0 commit comments

Comments
 (0)