Commit 72fac6f
Zo Bot
narrow TypeError guard in newtons_second_law_of_motion
The bare 'except Exception' around mass * acceleration was catching
RecursionError, MemoryError, KeyboardInterrupt, and any unrelated bug
in surrounding code. The multiplication of two Python objects can only
raise TypeError (wrong operand types) or OverflowError (very large
floats), so narrowing to TypeError matches the documented error path
and lets other exceptions propagate as designed.
Also adds a doctest that exercises the error path with a None
argument, so the new behavior is locked in by the test suite.1 parent 118197b commit 72fac6f
1 file changed
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| 73 | + | |
| 74 | + | |
73 | 75 | | |
74 | 76 | | |
75 | 77 | | |
| |||
0 commit comments