Bowler icon indicating copy to clipboard operation
Bowler copied to clipboard

return in finally swallows exceptions

Open iritkatriel opened this issue 1 year ago • 2 comments

In https://github.com/facebookincubator/Bowler/blob/92c9eeb7eebab8a1b65a989d0cf3b4947773ea2b/bowler/main.py#L88 there is a return statement in a finally block, which would swallow any in-flight exception.

This means that if an unhandled exception (including a BaseException such as KeyboardInterrupt) is raised from the try body, or any exception is raised from an except: clause, it will not propagate on as expected.

If the intention is to suppress all exceptions, I would propose to make this clear by using "except BaseException".

See also https://docs.python.org/3/tutorial/errors.html#defining-clean-up-actions.

iritkatriel avatar Oct 28 '24 17:10 iritkatriel

Hello! Can I take this issue?

raresdan avatar Nov 26 '24 20:11 raresdan

The issue at line 88 is the exec_module method being called on spec.loader without a proper null check or handling.

you can do .................

spec.loader.exec_module(module) # type: ignore

and...........\

`if path.exists(): if path.is_dir(): raise click.ClickException("running directories not supported")

spec = importlib.util.spec_from_file_location(path.name, path)
if spec is None or spec.loader is None:
    raise click.ClickException("Failed to load module specification")

module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)  # type: ignore

else: module = importlib.import_module(codemod) `

Shivangbijalwan avatar Dec 16 '24 18:12 Shivangbijalwan