Skip to content

feat: add built-in IPython traceback integration#157

Open
Question86 wants to merge 1 commit into
Qix-:masterfrom
Question86:feat/issue-10-ipython-support-v2
Open

feat: add built-in IPython traceback integration#157
Question86 wants to merge 1 commit into
Qix-:masterfrom
Question86:feat/issue-10-ipython-support-v2

Conversation

@Question86

Copy link
Copy Markdown

Summary

Adds first-class IPython support so better_exceptions works inside IPython shells, while preserving IPython behavior for cases that should still be handled by IPython.

Changes

  • Add better_exceptions/integrations/ipython.py:
    • install() / uninstall() (plus hook() / unhook() aliases)
    • Safe monkey patch of showtraceback
    • Delegates to IPython for:
      • SyntaxError
      • exception_only=True
      • filename/tb_offset paths
      • running_compiled_code=True
    • Handles older IPython showtraceback signatures that do not accept extra kwargs.
  • Update better_exceptions.hook() to auto-install the IPython adapter when running under IPython.
  • Add top-level load_ipython_extension() and unload_ipython_extension() so %load_ext better_exceptions works directly.
  • Add docs in README.md with %load_ext and programmatic usage.
  • Add test/test_ipython.py covering:
    • formatting regular exceptions
    • delegated special tracebacks
    • compatibility fallback for older IPython signatures
    • install/uninstall idempotency
    • extension entry points.

Validation

  • python -m py_compile better_exceptions/__init__.py better_exceptions/integrations/ipython.py test/test_ipython.py
  • PYTHONPATH=. python test/test_ipython.py
  • PYTHONPATH=. python test/test_logging.py

Closes #10

@Question86 Question86 mentioned this pull request May 20, 2026
@Question86

Copy link
Copy Markdown
Author

Follow-up on why this integration is structured this way:\n\n- Supports %load_ext better_exceptions directly via top-level load_ipython_extension, plus explicit integrations.ipython loading.\n- Keeps fallback behavior for special IPython paths (e.g. SyntaxError, �xception_only, compiled-code tracebacks) by delegating to original showtraceback.\n- Includes compatibility fallback for older IPython signatures that do not accept newer kwargs (e.g.
unning_compiled_code).\n- Keeps install/uninstall idempotent and tested, and �etter_exceptions.hook() auto-installs when running under IPython.\n\nIf you want this split into smaller commits (core hook vs docs/tests), I can do that quickly.

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.

ipython support

1 participant