Commit 286e905
authored
Replace BaseException with Exception across codebase (#8859)
## Summary
Fixes #7401
- Replaced all 17 occurrences of `except BaseException` with `except
Exception` across 13 files in `monai/` and `tests/`
- Catching `BaseException` inadvertently suppresses `KeyboardInterrupt`,
`SystemExit`, and `GeneratorExit`, which should nearly always propagate
- `Exception` is the appropriate base class for catchable errors in all
these contexts
## Files changed
- `monai/__init__.py`
- `monai/config/deviceconfig.py`
- `monai/utils/tf32.py`
- `monai/inferers/inferer.py`
- `monai/data/__init__.py`
- `monai/apps/auto3dseg/utils.py`
- `monai/apps/auto3dseg/ensemble_builder.py`
- `monai/apps/auto3dseg/data_analyzer.py`
- `monai/apps/detection/metrics/coco.py`
- `monai/apps/nnunet/nnunetv2_runner.py`
- `tests/test_utils.py`
- `tests/networks/nets/test_resnet.py`
- `tests/apps/detection/networks/test_retinanet.py`
## Test plan
- [x] All existing unit tests should pass without modification (this is
a strict narrowing of catch scope)
- [ ] Verify `KeyboardInterrupt` (Ctrl+C) is no longer silently
swallowed during long-running operations
Signed-off-by: Oleksandr Sanin <alexaaander.sanin@gmail.com>
---------
Signed-off-by: Oleksandr Sanin <alexaaander.sanin@gmail.com>
Signed-off-by: Oleksandr Yizchak Sanin <alexaaander.sanin@gmail.com>1 parent ef2acfb commit 286e905
13 files changed
Lines changed: 17 additions & 17 deletions
File tree
- monai
- apps
- auto3dseg
- detection/metrics
- nnunet
- config
- data
- inferers
- utils
- tests
- apps/detection/networks
- networks/nets
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
134 | | - | |
| 134 | + | |
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
341 | 341 | | |
342 | 342 | | |
343 | 343 | | |
344 | | - | |
| 344 | + | |
345 | 345 | | |
346 | 346 | | |
347 | 347 | | |
| |||
357 | 357 | | |
358 | 358 | | |
359 | 359 | | |
360 | | - | |
| 360 | + | |
361 | 361 | | |
362 | 362 | | |
363 | 363 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
216 | 216 | | |
217 | 217 | | |
218 | 218 | | |
219 | | - | |
| 219 | + | |
220 | 220 | | |
221 | 221 | | |
222 | 222 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
541 | 541 | | |
542 | 542 | | |
543 | 543 | | |
544 | | - | |
| 544 | + | |
545 | 545 | | |
546 | 546 | | |
547 | 547 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
200 | 200 | | |
201 | 201 | | |
202 | 202 | | |
203 | | - | |
| 203 | + | |
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
| |||
278 | 278 | | |
279 | 279 | | |
280 | 280 | | |
281 | | - | |
| 281 | + | |
282 | 282 | | |
283 | 283 | | |
284 | 284 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | | - | |
| 123 | + | |
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
121 | | - | |
| 121 | + | |
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
545 | 545 | | |
546 | 546 | | |
547 | 547 | | |
548 | | - | |
| 548 | + | |
549 | 549 | | |
550 | 550 | | |
551 | 551 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
| 74 | + | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| |||
0 commit comments