Narrow bare except: clauses in oinspect and interactiveshell by Carreau · Pull Request #15252 · ipython/ipython · GitHub
Skip to content

Narrow bare except: clauses in oinspect and interactiveshell#15252

Merged
Carreau merged 1 commit into
mainfrom
claude/focused-goldberg-gLkt6
Jun 12, 2026
Merged

Narrow bare except: clauses in oinspect and interactiveshell#15252
Carreau merged 1 commit into
mainfrom
claude/focused-goldberg-gLkt6

Conversation

@Carreau

@Carreau Carreau commented Jun 12, 2026

Copy link
Copy Markdown
Member

Narrow bare except: clauses so control-flow exceptions are no longer silently swallowed.

  • oinspect._getdef: bare except:except Exception so KeyboardInterrupt and SystemExit are no longer swallowed during signature rendering.
  • interactiveshell.safe_execfile / safe_execfile_ipy: bare except: on file-open probes → except OSError, which is the only exception that opening a file can legitimately raise. Prevents masking programmer errors and control-flow exceptions.

Cherry-picked from #15237. Rebased on current main.

oinspect._getdef: bare except → except Exception so KeyboardInterrupt
and SystemExit are no longer silently swallowed during signature rendering.

interactiveshell.safe_execfile / safe_execfile_ipy: bare except on file-open
probes → except OSError, which is the only exception that opening a file can
legitimately raise. Prevents masking programmer errors and control-flow
exceptions.

https://claude.ai/code/session_01VPnGTgifZ8HMAfiqEVftjj
@Carreau Carreau force-pushed the claude/focused-goldberg-gLkt6 branch from 571bce6 to 6ec2540 Compare June 12, 2026 19:24
@Carreau Carreau changed the title Replace bare except clauses with specific exception types Narrow bare except: clauses in oinspect and interactiveshell Jun 12, 2026
@Carreau Carreau merged commit 8344b1a into main Jun 12, 2026
27 checks passed
@Carreau Carreau added this to the 9.15 milestone Jun 26, 2026
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.

2 participants