PR #117895
tensorflow/tensorflow · Tools · Merged · 4 files changed
Replaced broad bare Exception handlers across 4 scripts in tensorflow/tools with explicit OS, subprocess, and value exception tuples so unexpected programming bugs surface immediately instead of being silently swallowed.
Checkout Pull Request
Inspect the full commit history and diff locally from upstream tensorflow/tensorflow.
$gh pr checkout 117895 --repo tensorflow/tensorflowReplaced broad bare Exception handlers across 4 scripts in tensorflow/tools with explicit OS, subprocess, and value exception tuples so unexpected programming bugs surface immediately instead of being silently swallowed.
File-by-File Modification Breakdown (4)
- +3 / -2
tensorflow/tools/git/gen_git_source.py
Upstream Python/C++ module implementation
- +4 / -2
tensorflow/tools/pip_package/redundant_tensorflow_gpu/setup.py
Upstream Python/C++ module implementation
- +4 / -2
tensorflow/tools/pip_package/redundant_tf_nightly_gpu/setup.py
Upstream Python/C++ module implementation
- +3 / -2
tensorflow/tools/tensorflow_builder/compat_checker/compat_checker.py
Upstream Python/C++ module implementation
Changed Files (4)
1. Introduction & Motivation
Build-time code generators and git-metadata scripts under tensorflow/tools used broad except Exception: clauses. While intended to recover gracefully when git is unavailable in tarball builds, catching Exception indiscriminately masked genuine programming bugs such as AttributeError, TypeError, and NameError [1].
2. Safety Invariant & Code Walkthrough
Let . Narrowing catch blocks enforces strict fault isolation:
3. References
- Python Software Foundation, PEP 8 & Built-in Exception Hierarchy (
docs.python.org/3/library/exceptions.html).