Skip to content

fix: bare except in checkpoint loader swallows KeyboardInterrupt - #10

Open
andrewwhitecdw wants to merge 1 commit into
NVIDIA:mainfrom
andrewwhitecdw:bugfix/train-bare-except-in-checkpoint-loader
Open

andrewwhitecdw wants to merge 1 commit into
NVIDIA:mainfrom
andrewwhitecdw:bugfix/train-bare-except-in-checkpoint-loader

Conversation

@andrewwhitecdw

Copy link
Copy Markdown

This PR addresses the following issue in train.py: bare except in checkpoint loader swallows KeyboardInterrupt.

Changes

  • train.py: bare except in checkpoint loader swallows KeyboardInterrupt.

Details

--- a/train.py
+++ b/train.py
@@ -1,1 +1,1 @@
-        except:
+        except Exception:

Tests

  • tests/test_no_bare_except.py
--- /dev/null
+++ b/tests/test_no_bare_except.py
@@ -0,0 +1,17 @@
+import ast
+import os
+import unittest
+
+
+class TestNoBareExcept(unittest.TestCase):
+    def test_train_py_has_no_bare_except(self):
+        path = os.path.join(os.path.dirname(__file__), '..', 'train.py')
+        with open(path) as f:
+            tree = ast.parse(f.read())
+        bare_handlers = [
+            node.lineno
+            for node in ast.walk(tree)
+            if isinstance(node, ast.ExceptHandler) and node.type is None
+        ]
+        self.assertEqual(bare_handlers, [], "train.py contains bare except: handlers")
+
+
+if __name__ == '__main__':
+    unittest.main()

@andrewwhitecdw

Copy link
Copy Markdown
Author

Closing after multiple repair attempts: original patch no longer applies or auditor feedback remains unaddressed.

@andrewwhitecdw
andrewwhitecdw deleted the bugfix/train-bare-except-in-checkpoint-loader branch August 2, 2026 23:56
@andrewwhitecdw
andrewwhitecdw restored the bugfix/train-bare-except-in-checkpoint-loader branch August 17, 2026 20:32
@andrewwhitecdw

Copy link
Copy Markdown
Author

script closed on accident

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