Skip to content

fix: replace bare except with except BaseException in utils.py#341

Open
harshadkhetpal wants to merge 1 commit into
lebedov:masterfrom
harshadkhetpal:fix/bare-except-utils
Open

fix: replace bare except with except BaseException in utils.py#341
harshadkhetpal wants to merge 1 commit into
lebedov:masterfrom
harshadkhetpal:fix/bare-except-utils

Conversation

@harshadkhetpal
Copy link
Copy Markdown

Summary

Replace bare except: with except BaseException: in skcuda/utils.py.

Bare except: catches all exceptions including KeyboardInterrupt, SystemExit, and GeneratorExit. Since this block immediately re-raises a RuntimeError, except BaseException: is the correct replacement — it preserves interrupt semantics while making the intent explicit.

Change:

# Before
try:
    p = subprocess.Popen(cmds, stdout=subprocess.PIPE, ...)
    out = p.communicate()[0].decode()
except:
    raise RuntimeError('error executing {0}'.format(cmds))

# After
try:
    p = subprocess.Popen(cmds, stdout=subprocess.PIPE, ...)
    out = p.communicate()[0].decode()
except BaseException:
    raise RuntimeError('error executing {0}'.format(cmds))

Testing

No behavior change for normal exception paths — correctness fix only.

Bare `except:` catches all exceptions including KeyboardInterrupt.
Since this block re-raises a RuntimeError, use except BaseException:
to preserve interrupt semantics while making the intent explicit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant