Skip to content

Replace bare except with except Exception#13550

Closed
Ricardo-M-L wants to merge 1 commit intohuggingface:mainfrom
Ricardo-M-L:fix/replace-bare-except-with-exception
Closed

Replace bare except with except Exception#13550
Ricardo-M-L wants to merge 1 commit intohuggingface:mainfrom
Ricardo-M-L:fix/replace-bare-except-with-exception

Conversation

@Ricardo-M-L
Copy link
Copy Markdown
Contributor

What does this PR do?

Replaces 3 bare except: clauses with except Exception:.

Bare except: catches SystemExit and KeyboardInterrupt, which prevents graceful shutdown (e.g. Ctrl+C during a download in hub_utils.py would be silently swallowed instead of interrupting the process).

except Exception: preserves the original error-handling behavior while allowing system-exiting exceptions to propagate normally.

Locations

File Line Context
utils/hub_utils.py 301 Fallback variant download path
experimental/rl/value_guided_sampling.py 60 Dataset mean computation
experimental/rl/value_guided_sampling.py 66 Dataset std computation

Who can review?

Anyone in the community is free to review the PR. @yiyixuxu @sayakpaul

Bare `except:` clauses catch `SystemExit` and `KeyboardInterrupt`,
preventing graceful shutdown and making the process uninterruptible.

Replace with `except Exception:` which preserves the original
error-handling behavior while allowing system-exiting exceptions
to propagate.

Affected locations:
- utils/hub_utils.py:301 — fallback download path
- experimental/rl/value_guided_sampling.py:60,66 — dataset stat computation

Signed-off-by: Ricardo-M-L <Sibyl_Hartmanbnb@webname.com>
@github-actions github-actions Bot added utils experimental size/S PR with diff < 50 LOC labels Apr 22, 2026
@Ricardo-M-L
Copy link
Copy Markdown
Contributor Author

Closing this in favor of the substantive bug fixes I have open in the queue. The bare except: cleanup is low-priority and shouldn't compete for review attention with the actual crash/AttributeError fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

experimental size/S PR with diff < 50 LOC utils

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant