Debugging Stories from an Advanced Python Class
summary
Four concrete Python debugging stories with reproducible code and fixes: a broad except hiding a NameError fixed by catching specific exceptions; redefining builtins breaking input by shadowing names, fixed by avoiding reserved names; using unittest.mock.patch with side_effect set to a string causing iteration over characters (use a list or tuple instead); and applying MagicMock to a module reference leaking changes to other tests, fixed by backing up and restoring the original function.
AI-written summary · about
chapters (7)
- 0:00Introduction
- 1:09File not found exception
- 3:37Input function error
- 7:08Code validation and unit tests
- 12:08Reusing code blindly
- 13:12Copy vs reference issues
- 16:45Takeaways and closing
related talks
12mDebugging Python in Production: Practical Techniques Beyond Print Statements
28mHere be dragons: some elegant and ugly hacks in CPython
18mHunting the Bugs
31mDon't Do This
43m5 Years of Bad Ideas
43m5 Years of Bad Ideas
01h 27mBest Practices for Debugging
41mAdvanced Python Debugging Techniques Using GDB
