← Winnitude! Search  ·  Reader Mode (1001 ms)
Links: Stay in Reader Retro Site Converter Retro Mode: OFF Original Page ↗
GITHUB · 27 LINKS

fix: replace bare except clauses with except Exception in inspection.py by koteshyelamati · Pull Request #1056 · bpython/bpython

Repository navigation

fix: replace bare except clauses with except Exception in inspection.py - #1056


Open
koteshyelamati wants to merge 1 commit into bpython:main from koteshyelamati:main
Open

fix: replace bare except clauses with except Exception in inspection.py #1056 koteshyelamati wants to merge 1 commit into bpython:main from koteshyelamati:main

Conversation

koteshyelamati commented Jul 23, 2026



Copy link Copy Markdown

Summary

Replace two bare except: clauses in bpython/inspection.py with except Exception:.

Changes

Line 272 -- getattr(f, "__name__", None) can raise if the object has a descriptor that throws:

# Before
except:

# After
except Exception:

Line 282 -- comment notes this catches xmlrpclib.Fault, which is an Exception subclass (see issue #202 ):

# Before
except:

# After
except Exception:

Why

Bare except: catches BaseException, including SystemExit and KeyboardInterrupt. All exceptions thrown here are Exception subclasses, so except Exception: is correct and safer.

fix: replace bare except clauses with except Exception in inspection.py e5aecf2

sebastinas commented Jul 24, 2026 · edited Loading



Copy link Copy Markdown
Contributor

getattr may run arbitrary code from the user (via the object's __getattribute__) which may throw arbitrary exceptions. So in the first instance we definitely want to catch everything.

codecov
Bot
commented Jul 24, 2026



Copy link Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.04%. Comparing base (1a919d3 ) to head (e5aecf2 ).
⚠️ Report is 47 commits behind head on main.

Files with missing lines Patch % Lines
bpython/inspection.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1056      +/-   ##
==========================================
- Coverage   76.51%   76.04%   -0.48%     
==========================================
  Files          62       61       -1     
  Lines        8308     8261      -47     
==========================================
- Hits         6357     6282      -75     
- Misses       1951     1979      +28     

☔ View full report in Codecov by Harness .
📢 Have feedback on the report? Share it here .

🚀 New features to boost your workflow:
  • ❄️ Test Analytics : Detect flaky tests, report on failures, and find test suite problems.
Sign up for free to join this conversation on GitHub . Already have an account? Sign in to comment

Labels

None yet

2 participants